syntax of or in php

-2

I have this condition in php

if ($Parametros[1] != "Pedidos" or $Parametros[1] != "Presupuestos") { }

The idea is that if $Parametros[1] is not "Pedidos" or "Presupuestos" that is executed what is inside the brackets.

for some reason it does not work for me :( I tried to put it in parentheses but not

if (($Parametros[1] != "Pedidos")or($Parametros[1] != "Presupuestos")) {

if I put only one condition if it works, but with the or no.

if ($Parametros[1] != "Pedidos") { }

What is wrong with the condition so that it does not run?

    
asked by Killpe 26.12.2017 в 14:23
source

1 answer

7
  

The idea is that if $ Parameters [1] is not "Orders" or "Budgets" that   whatever is left inside the brackets.

Your logic is wrong, You are asking if the value of an element of an array is not Pedidos or No Presupuestos . If it is Pedidos , it is definitely not Presupuestos and if it is Presupuestos it is definitely not Pedidos . Therefore, that statement always returns true .

The logical operator should be a and for me to evaluate the two conditions.

if ($Parametros[1] != "Pedidos" and $Parametros[1] != "Presupuestos" )
    
answered by 26.12.2017 / 15:09
source