1
I have the following examples of condition in ternario, in the first example it works correctly, it returns me the data and if it is empty returns null,
however in the second example I think would be correct, it returns me the data correctly but does not return me null when empty.
Example 1:
$data->mala_grande = ($t->malagrande) ? $t->malagrande :null;
Example 2
$data->mala_grande = (isset($t->malagrande)) ? $t->malagrande :null;
- Would you be doing something wrong using this first example without the
isset? - I can continue on this option?
- The first option Without putting the
issetshe would be playing the same role automatically?
isset()not to test if it’s empty.empty()is to test if it’s empty.– Bacco
o the problem is that with Empty() the same thing occurs
– Fabio Henrique
I complemented the answer and put another example. I hope you answer.
– Bacco