I think this is an older way of doing something in PHP. Can anyone point me to a decent document on it, or even describe what this line is doing?
Thanks
Jason
$Delimiter = empty($xml->DELIMITER->attributes()->value) ? "\t" : chr($xml->DELIMITER->attributes()->value);
Anyone know what this is?
Moderator: General Moderators
Re: Anyone know what this is?
The line makes use of the Ternary operator.
The expression "A ? B : C" means: if A is true, evaluate to B, otherwise evaluate to C.
In this case, A is checking whether the value is empty with the empty() function. If it is, the expression evaluates to "\t". If not, it evaluates to the value itself.
It's a common use of the ternary operator: using a default value if a value is not set.
The expression "A ? B : C" means: if A is true, evaluate to B, otherwise evaluate to C.
In this case, A is checking whether the value is empty with the empty() function. If it is, the expression evaluates to "\t". If not, it evaluates to the value itself.
It's a common use of the ternary operator: using a default value if a value is not set.
Re: Anyone know what this is?
That makes sense. Thanks for clearing it up.