Kevin Powell - CommunityKP-C
Kevin Powell - Community•3y ago•
7 replies
foggy

PHP - What's going on here?

Hi.. Quite new to LAMPy stuff - I'm trying to pick apart a bit of code here. Can someone explain what's going on? I get what it's doing, I just can't put a name to the functionality to explore it further if that makes sense.

php > unset ($error); php > echo (empty($error)) ? 'The string is empty' : 'The string has something in'; The string is empty php > $error = "Something"; php > echo (empty($error)) ? 'The string is empty' : 'The string has something in'; The string has something in php >

Obviously the ? and : is doing some decision making based on a true/false from the empty($error) - is this part of 'echo' or something else? Googling "PHP echo ? :" doesn't yield much of interest 🙂

cheers!
Was this page helpful?