Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP basic comparison with negative

Tags:

php

I cannot find an answer to this and I am sure it is right in front of me. How do I say in PHP as part of an IF statement the following:

if NOT ( (variable1 == 10) && (variable2 == 20) )

Thanks!

like image 932
TheRealPapa Avatar asked Dec 07 '25 02:12

TheRealPapa


1 Answers

You can use ! to achieve this

if ( (variable1 != 10) || (variable2 != 20) )

Or simply

if (!((variable1 == 10) && (variable2 == 20)))
like image 190
Fabio Avatar answered Dec 08 '25 16:12

Fabio