0

When I use this if construction with parenthesis

if ($_POST['type']!='1' || ($_POST['type']=='1' && $_POST['prepayment']=='2'))
{
     do this and that 
} 

I get a PHP error:

Fatal error : Call to undefined function () in .....

What's wrong?

5
  • use it as if (($_POST['type'] != '1') || ($_POST['type'] == '1' && $_POST['prepayment'] == '2')) { Commented Jun 17, 2016 at 6:03
  • 1
    There isn't any error with the code, check this. eval.in/590545 Commented Jun 17, 2016 at 6:06
  • Still Fatal Error. I use PHP 5.5.15 - maybe PHP wrong settings ? Commented Jun 17, 2016 at 6:43
  • Could you paste the full error message? Does the line number match the if block? Commented Jun 17, 2016 at 6:51
  • Fatal error : Call to undefined function () in path/file.php on line 274. The line number matches exactly the if block Commented Jun 17, 2016 at 7:18

1 Answer 1

1

Since the function name is given as "" (nothing), the only reasonable cause for this is a wrong whitespace character before (, e.g. an IDEOGRAPHIC SPACE U+3000, or something of that sort. PHP recognises that as not-a-space but some-Unicode-character, which is a valid function name. E.g. 漢字() would be a valid function call, so is  () (that's a full-width space character).

Check your spaces and/or retype that line.

Sign up to request clarification or add additional context in comments.

4 Comments

I removed whitespace and its gone. To check it, I inserted the spaces again but it's still gone - weired. Maybe this is an error of the script interpreter / compiler. I'll watch this and come back later.
Again, this easily happens if you inadvertently insert some weird whitespace characters. Perhaps you're typing with an IME in a foreign language which may contain such characters, or you've copy and pasted from a weird source.
Constantly happening to me, accidentally press some combination of Shift, Ctrl, and Space which results in a non-breaking space which renders as a space in editors.
@deceze - Well I use XCode as editor with UTF-8 - really weired. I accept youre answer but might come back to report upcoming errors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.