I know how to do something like this in Perl, but not sure how to do it the correct way in Php...
Say I have a string called: $string
What is the proper way to do this:
echo "Code is " . ($string || "Great");
So it would print $string to the browser, IF it had value, otherwise it would print "Great" to the browser.
do I have to use a if statement or is there a way to do it like this:
($string == "s1") ? 's2':'s1'
Sorry for my Php Ignorance :)
-Richard
echo "Code is " . ($string ?: "Great");Read about the conditional ternary operator.