Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expecting statement?

Tags:

php

phpstorm

I have created a file that contains general functions. The goal of this file is include it inside the main file and use the functions available in it.

Anyway at the top of all, so <?php PhpStorm return:

Expecting Stament

what does mean?

an example of the file structure:

<?php //here the problem


public function getTimeStamp()
{
    $originalTime = microTime(true);
    $micro = sprintf("%06d", ($originalTime - floor($originalTime)) * 1000000);
    $date = new DateTime(date('d-m-Y H:i:s' . $micro, $originalTime));

    return $date->format($this->settings['dateFormat']);

} //and also here

 ...

?>

what I did wrong?

like image 716
Sandokan Avatar asked Feb 04 '16 10:02

Sandokan


2 Answers

Your problem is that you have defined it as a public function when you are outside of a class.

Simply change

public function getTimeStamp()

to

function getTimeStamp()
like image 82
Tom Wright Avatar answered Sep 30 '22 14:09

Tom Wright


Make sure you haven't declared a function within another function. That will cause this error as well. For example:

class bob {

   public function process(){

      // bunch of code here

       protected function hello() {
           //wrong spot!
       }
   }
}
like image 27
Andrew Avatar answered Sep 30 '22 16:09

Andrew