How to read this php variable?
$ignore = (in_array($dynamic_url,$ignore_pages))?true:false;
This is the so-called ternary operator.
Syntax:
Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΎΠ΅_ΡΡΠ»ΠΎΠ²ΠΈΠ΅ ? Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠ΅_1 : Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠ΅_2
If logical_condition is true (returns true), then the first expression to the left of the colon is taken (or calculated), if false is returned, then the second expression to the right of the colon is taken.
I understand that there is a $ ignore variable, and depending on what the function returns
in_array($dynamic_url,$ignore_pages);
It is set to true or false. And what exactly is transferred there and where this whole matter is then applied depends on the rest of the code.
The ternary operator has already been answered, and I will add that
$ignore = (in_array($dynamic_url,$ignore_pages))?true:false;
doesn't have any sense because in_array
returns a bool
and this:
$ignore = in_array($dynamic_url,$ignore_pages);
will be sufficient.
Source: https://ru.stackoverflow.com/questions/968637/
All Articles