Skip to content
Advertisement

PHP – Multiple OR operators in if statement

I am working with getters and setters within my Symfony project. I have to use if() statement to check if status field does not have specific values before changing other field.

Code:

JavaScript

I defined constants and also using OR operator. I was wondering if there is more elegant solution than this. Maybe is_array() function, but don’t know can it be used in this contest?

Advertisement

Answer

I think you should do something like this

JavaScript

Passing your constants in an array and the check if you status is in_array.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement