You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');
Well, in PHP, that doesn't work. What many do is:
if ( empty($name) ) $name = 'joe';
Which works...but it's a bit verbose. My preference, at least for checking for empty strings, is:
$name = $name ?: 'joe';
What's your preference for setting values if they don't already exist?
I just used : if ( empty($name) ) $name = 'joe';
This is more a kind of "human readable", for me .
I used for setting the opacity of a php image processing app, so i can update the main app later, because i'm using a slider input on app test version but i still using the same URL for processing the images, with caused bug because of a missing variable (opacity) .
Thank you .