Jump to content

Parse error


richlacey

Recommended Posts

Hi there, just wondering if anyone could cast there eyes over this, my error is

 

Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' on line 197

 

this is line 197 of the file with the error,

 

<input type="text" class="form-control" name="dob" id="dob" value="<?=(new DateTime($member['dob']))->format("d/m/Y");?>">

 

This was working not sure what has happend?

 

Thanks for your help

 

Rich

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/291049-parse-error/
Share on other sites

It could also have to do with your PHP vesion. Older versions require you to instance the object and later use it.

See this code here:

<?php

class Test
{
  public function test() { return 'a'; }
}

echo (new Test())->test();

If you copy it into this tool you will see that versions below PHP 5.4 give a PARSE ERROR just like yours.

You would need to use

<?php

$object = new Test();
echo $object->test();

Hope this helped.

Link to comment
https://forums.phpfreaks.com/topic/291049-parse-error/#findComment-1491037
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.