Link Posted January 1, 2008 Share Posted January 1, 2008 I have a class defined as below. Like six is the first 'const' definition. Any clue why I am getting this error? I even tried implementing an interface as you can see from the comments. I am used to OOP in Java, so I am probably just doing something completely wrong. Thanks in advance! <?php /*interface MessageConstants { const $ERROR = 0; const $SUCCESS = 1; }*/ class Message {//implements MessageConstants { var $type; var $title; var $message; const ERROR = 0; const SUCCESS = 1; function message($type, $title, $message) { $this->type = $type; $this->title = $title; $this->message = $message; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84004-parse-error-syntax-error-unexpected-t_const/ Share on other sites More sharing options...
trq Posted January 1, 2008 Share Posted January 1, 2008 What version of php are you using? Quote Link to comment https://forums.phpfreaks.com/topic/84004-parse-error-syntax-error-unexpected-t_const/#findComment-427470 Share on other sites More sharing options...
Link Posted January 1, 2008 Author Share Posted January 1, 2008 PHP Version 4.4.7 Quote Link to comment https://forums.phpfreaks.com/topic/84004-parse-error-syntax-error-unexpected-t_const/#findComment-427474 Share on other sites More sharing options...
trq Posted January 1, 2008 Share Posted January 1, 2008 Class constants do not exist untill php 5 and higher. Quote Link to comment https://forums.phpfreaks.com/topic/84004-parse-error-syntax-error-unexpected-t_const/#findComment-427484 Share on other sites More sharing options...
Link Posted January 1, 2008 Author Share Posted January 1, 2008 at all? There's no way to create a non-variable "variable" (sorry for the wording...haha) Quote Link to comment https://forums.phpfreaks.com/topic/84004-parse-error-syntax-error-unexpected-t_const/#findComment-427486 Share on other sites More sharing options...
trq Posted January 1, 2008 Share Posted January 1, 2008 Not within a class, no. Not untill php5. Quote Link to comment https://forums.phpfreaks.com/topic/84004-parse-error-syntax-error-unexpected-t_const/#findComment-427488 Share on other sites More sharing options...
PFMaBiSmAd Posted January 1, 2008 Share Posted January 1, 2008 The end of life of php4 has already happened. Except for security patches no new versions of php4 will be released. Everyone should have their schedule in place for upgrading to the latest version of php5. Your web host might already have php5 available. Check with them how to switch or what their schedule is to upgrade. Quote Link to comment https://forums.phpfreaks.com/topic/84004-parse-error-syntax-error-unexpected-t_const/#findComment-427495 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.