Search code examples
phpif-statementundefined-function

IF / OR statement causes Call to undefined function() error. Why?


I have seen this error message a few times and even after googling quite some time I'm really unable to figure out what is wrong:

$uid = GNGHelper::getLoggedInUserID();
$assignedGuideID = $tour->get('guide')->get('juser_id');
$isCoord = GNGHelper::isLoggedInUserCoord();

if (($uid == $assignedGuideID) || ($isCoord === true)) {}

I get the following error pointing to the if statement:

Fatal error: Call to undefined function () in /home/gonative/public_html/dev/modules/mod_gngtourdetails/mod_gngtourdetails.php on line 51

What is wrong with this if statement?

Thanks a lot! W.


Solution

  • @Kaddath: Thanks! You got it!!! I removed all extra spaces from the line everywhere and now it works. I still don't understand why, but at least it works. This is my corrected line: if(($uid == $assignedGuideID)||($isCoord === true)){ – wanderlusted 17 hours ago
    1 if there were a hidden character before a ( and PHP detected it, it was understood as a function call. Another reason why we should be careful with copy/paste!! – Kaddath 2 hours ago