uniique Posted August 14, 2012 Share Posted August 14, 2012 Hello, I get a weird error from this part of code Line 181 if (!empty(self::SLAVE1_HOST)) { Parse error: syntax error, unexpected ')', expecting '(' in *** on line 181 What is wrong with this part of code? Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/ Share on other sites More sharing options...
jazzman1 Posted August 14, 2012 Share Posted August 14, 2012 If you replaced self::SLAVE1_HOST with $var, what happened? if(!empty ($var)){ } Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369261 Share on other sites More sharing options...
uniique Posted August 14, 2012 Author Share Posted August 14, 2012 then it works ^^ so i have to put self::SLAVE1_HOST into a $var and it will work then? Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369263 Share on other sites More sharing options...
jazzman1 Posted August 14, 2012 Share Posted August 14, 2012 then it works ^^ so i have to put self::SLAVE1_HOST into a $var and it will work then? No, start from here -> http://php.net/manual/en/language.oop5.php Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369266 Share on other sites More sharing options...
uniique Posted August 14, 2012 Author Share Posted August 14, 2012 I was rather hoping to get a short hint instead of pointing me to the manual Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369270 Share on other sites More sharing options...
jazzman1 Posted August 14, 2012 Share Posted August 14, 2012 I was rather hoping to get a short hint instead of pointing me to the manual Yes, but everything is there You have to post the class, b/s I don't know the structure. Try if (!self::SLAVE1_HOST)) Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369273 Share on other sites More sharing options...
uniique Posted August 14, 2012 Author Share Posted August 14, 2012 this is the Class Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369275 Share on other sites More sharing options...
jazzman1 Posted August 14, 2012 Share Posted August 14, 2012 You need learn more of OOP and PDO. In this case use: if (self::SLAVE1_HOST)) Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369281 Share on other sites More sharing options...
uniique Posted August 14, 2012 Author Share Posted August 14, 2012 It's not my class, I use it as a wrapper for PDO, I was just wondering, why this error occurs. So one can only perform empty on $vars? Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369284 Share on other sites More sharing options...
jazzman1 Posted August 14, 2012 Share Posted August 14, 2012 It's not my class, I use it as a wrapper for PDO, I was just wondering, why this error occurs. So one can only perform empty on $vars? B/s empty and isset function doesn't work with constants. Simple test: define("CONSTANT", "Hello world."); if(empty (CONSTANT)){ echo CONSTANT; } else if(isset(CONSTANT)){ echo '....'; } else { echo CONSTANT; } You have to use defined() if (defined('CONSTANT')) { echo CONSTANT; } Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369293 Share on other sites More sharing options...
uniique Posted August 14, 2012 Author Share Posted August 14, 2012 ok, thanks for the explanation Quote Link to comment https://forums.phpfreaks.com/topic/267056-weird-error/#findComment-1369357 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.