T_PAAMAYIM_NEKUDOTAYIM error in PHP

Today I’ve encountered a very strange error which was quite similar to Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in….
At the first look I thought it’s a joke from the second programmer I’ve been working with but I was wrong.

This error is addressing to Scope Resolution Operator (::).
The problem is that this error can happen in quite unpredictable places – like in my example:

define('IPHONE',true);
 
[...]
 
if(defined(IPHONE)){
	$mediumlimit = " AND (Media=0 OR Media=2)";
} else {
	$mediumlimit = " AND (Media=0 OR Media=1)";
}

Line if(defined(IPHONE)){ was throwing an error.
When I’ve added quotes around IPHONE constant name the error was gone!

Sometimes error messages can cause headache when they are weird and completely not related to actual code – god bless google for letting me fix it in no time!

Leave a Reply

Your email address will not be published. Required fields are marked *