![]() |
Conditional doesn't trigger error, but doesn't work?
So in my effort to reduce using functions such as preg_match, I tried this little bit of code in a method today:
PHP Code:
PHP Code:
-m |
Its the brackets. ( 'categories' || 'versions' ) would evaluate to TRUE on its own - so the comparison you're actually doing is:
PHP Code:
PHP Code:
|
Yeah I had it working that way originally, then I decided to see if I could find crafty new ways of doing it, just to see what was possible.
I guess while I know it doesn't work, it doesn't fully make sense to me the reasoning why. In english, I would read that as ( IF variable NOT EQUAL TO (string OR string) ), not ( IF variable NOT EQUAL TO true ). See what I mean? -m |
Think of it like maths - everything in brackets gets evaluated first i.e.
PHP Code:
Edit: I would read it as: IF variable NOT EQUAL TO (string OR string) in the same way as you, but I would see that: (string OR string) == true since everything in brackets gets evaluated first. |
| All times are GMT. The time now is 09:41 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0