0

I just started working with Facebook sdk and I am following the packet code example. But when I start running it, it gave me many errors but was able to fix them by referring to this, but this I couldn't fix this error:

HTTP Status 500 - java.lang.RuntimeException: PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\Users\HP USER\Downloads\Apache Tomcat \GraphSessionInfo.php on line 90

java.lang.RuntimeException: PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in \GraphSessionInfo.php on line 90

Error refered to the below code

public function getIssuedAt()
{
    $stamp = $this->getProperty('issued_at');
    if ($stamp) {
        return (new \DateTime())->setTimestamp($stamp);  **//line 90**
    } else {
        return null;
    }
}
helmbert
  • 35,797
  • 13
  • 82
  • 95
Jack
  • 1
  • 1

1 Answers1

0

Calling class methods directly after instantiation (sth. like (new \DateTime())->setTimestamp(...)) was added in PHP 5.4 and was not supported in prior versions (also see the official documentation).

When you are using an older PHP version (probably 5.3 from the looks of it), you will need to store the constructor result in a variable before calling additional methods on that object:

$datetime = new \DateTime();
return $datetime->setTimestamp($tstamp);

You should also consider that PHP 5.3 has reached it's end-of-life in August 2014 and is not supported anymore. Consider upgrading to a newer version (since you appear to be running PHP in a Java servlet container, this might not be trivial, though).

Community
  • 1
  • 1
helmbert
  • 35,797
  • 13
  • 82
  • 95