The Little Guy Posted February 27, 2010 Share Posted February 27, 2010 I have this: <?php class Main{ protected $socket; public function __construct(){ // Line 4 } And I am getting this error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/ryannaddyps/processes/Classes/Main.php on line 4 I have never seen this before, and I can not find the problem... Link to comment https://forums.phpfreaks.com/topic/193587-parse-error/ Share on other sites More sharing options...
salathe Posted February 27, 2010 Share Posted February 27, 2010 You're using PHP 4 which does not use the __construct style of constructor. You should instead name the constructor method as Main: see http://php.net/oop4.constructor Link to comment https://forums.phpfreaks.com/topic/193587-parse-error/#findComment-1019067 Share on other sites More sharing options...
The Little Guy Posted February 27, 2010 Author Share Posted February 27, 2010 I think you have that backwards.... accordding to php.net php5 uses __construct for a constructor. Link to comment https://forums.phpfreaks.com/topic/193587-parse-error/#findComment-1019068 Share on other sites More sharing options...
The Little Guy Posted February 27, 2010 Author Share Posted February 27, 2010 I think I have may found the problem my server is running php 4.4.9.... I want 5.x.x I'll get back to you... Link to comment https://forums.phpfreaks.com/topic/193587-parse-error/#findComment-1019072 Share on other sites More sharing options...
The Little Guy Posted February 27, 2010 Author Share Posted February 27, 2010 OK I talked to tech support, and I had to: a. Rename the file from "server.php" to "server" b. use this like of code (instead of the one I was using) "#!/usr/local/php5/bin/php -q" and now I am running php 5.x.x and my error messages went away! Link to comment https://forums.phpfreaks.com/topic/193587-parse-error/#findComment-1019075 Share on other sites More sharing options...
salathe Posted February 27, 2010 Share Posted February 27, 2010 I think you have that backwards.... Nah, I said you were using PHP 4 (you were!). Good to see you got it sorted. Link to comment https://forums.phpfreaks.com/topic/193587-parse-error/#findComment-1019078 Share on other sites More sharing options...
The Little Guy Posted February 27, 2010 Author Share Posted February 27, 2010 I think you have that backwards.... Nah, I said you were using PHP 4 (you were!). Good to see you got it sorted. I thought you meant my syntax was php 4 Link to comment https://forums.phpfreaks.com/topic/193587-parse-error/#findComment-1019082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.