19
rant1ng
6y

Hey... to somebody reading this, most likely.

The problem, is that you put if($var = 'something')
You need ==, not =.
Php doesn't tell you that though. It'll just change the var to 'something'

That's why you're getting that really obscure, doesn't make any sense error.

You're welcome.

Comments
  • 11
    Fun fact, what @irene is suggesting is a standard technique sometimes called Yoda notation or Yoda conditionals (because it's like Yoda's often-inverted grammar). Useful.
  • 3
    Same is with js and python when you want to send a function as argument and put the () behind them. It will just execute instead of pass through. Gave me plenty of headaches.
  • 2
    @RememberMe @irene I just googled that... I never knew about this.
  • 0
    Same with this..

    if(
    $someCheckVar
    && $weNeedThis = 'yo'
    ) // weneedthis: "yo"

    if(
    $weNeedThis = 'yo'
    && $someCheckVar
    ) // weneedthis: true
  • 0
    Use IDE. 😆
  • 2
    In C, you can do the same, but any decent C compiler will display a warning.
  • 3
    $var = 5..

    If you want it to be 7, you have to use = 7, not = 5.

    Php doesn’t tell you that..

    You’re welcome 😂
  • 0
    So cute
  • 1
Add Comment