Use the '||=' or '|='operator.
For instance,
$color ||= 'Green';
will set $color to 'Green' if it is empty, undefined or contains zero. Otherwise it will retain its original value.
For instance,
$color ||= 'Green';
will set $color to 'Green' if it is empty, undefined or contains zero. Otherwise it will retain its original value.
No comments :
Post a Comment