OR in if condition raises "unexpected T_VARIABLE" error [closed]
I'm stuck. I just want a simple OR inside an if condition and php always raises an error:
My Code:
if( ($value > 0.01 || $seconds < 100) ):
Error:
Parse error: syntax error, unexpected T_VARIABLE
I've been struggling with the same problem, and now I finally decided to get to the bottom of it. Turns out the space character that I had after the || operator isn't actually space (= %20), it's %A0 (no idea how that happened). I'm using gEdit on Ubuntu, seems like Windows/Notepad treats them both as regular space.
So the lesson here is, check that your characters really are what you think they are.
change your code into this:
if(($value > 0.01)||($seconds < 100))
{
}
hope it works! :)
You need to provide more code, The following code works at my computer:
<?php
$value = 2;
$seconds = 10;
if( ($value > 0.01 || $seconds < 100) ) {
echo("OK");
} else {
echo("fail");
}
?>
精彩评论