![]() ![]() The queried content displays correctly and is organized just fine. ![]() Within each ” cell in a row below the heading ($row_getResults). I have a table in a loop that displays results of runners organized by age ($row_getResults) then organized by whether they ran the ‘1 Mile’ ($row_getResults) or the ‘8K’. How would I create a condition statement for the following situation: Basic True / False Declaration $is_admin = ($user = 'admin') ? true : false Conditional Welcome Message echo 'Welcome '.($user ? $user : 'Guest').'!' Conditional Items Message echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.' Conditional Error Reporting Level error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT) Conditional Basepath echo '' Nested PHP Shorthand echo 'Your score is: '.($score > 10 ? ($age > 10 ? 'Average' : 'Exceptional') : ($age > 10 ? 'Horrible' : 'Average') ) Leap Year Check $is_leap_year = ((($year % 4) = 0) & ((($year % 100) != 0) || (($year %400) = 0))) Conditional PHP Redirect header('Location: '.($valid_login ? '/members/index.php' : 'login.php?errors=1')) exit() I've gone through my code library and picked out some examples of ternary operator usage. ![]() In looking at my Google Analytics statistics, I see a lot of visitors searching for PHP shorthand if/else (ternary) information. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |