19
rant1ng
7d

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
    It's a child's mistake. Put constant first and php will tell you you've fucked up.
  • 14
    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.
  • 4
    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
  • 3
    @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. 😆
  • 3
    In C, you can do the same, but any decent C compiler will display a warning.
  • 5
    $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 😂
  • 1
    So cute
  • 1
Your Job Suck?
Get a Better Job
Add Comment