richlacey Posted September 13, 2014 Share Posted September 13, 2014 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 More sharing options...
Barand Posted September 13, 2014 Share Posted September 13, 2014 you need to add parentheses echo (new DateTime('2014-09-13'))->format('d/m/Y'); //---> 13/09-2014 Link to comment https://forums.phpfreaks.com/topic/291049-parse-error/#findComment-1491006 Share on other sites More sharing options...
Csharp Posted September 14, 2014 Share Posted September 14, 2014 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.