canadian_angel Posted June 14, 2010 Share Posted June 14, 2010 I have to use an if statement to print the string youth message to a browser if an integer variable $age is between 18-35 and if age contains any other value the string generic message displays-so far i got this and both messages display ugh! <?php // Address error handling. ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); // Validate the age. if ('$age = 18 - 35') { print '<p>Youth Message!</p>'; } else { $age .=$age; } // End of 1st conditional. if ('$age => 35') { print '<p>Generic Message!</p>'; } else { $age .=$age; } // End of 2nd conditional. ?> Link to comment https://forums.phpfreaks.com/topic/204755-got-a-problem-trying-to-get-this-to-work-right/ Share on other sites More sharing options...
hcdarkmage Posted June 14, 2010 Share Posted June 14, 2010 Try this <?php // Address error handling. ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); // Validate the age. if ($age >= 18 || $age < 35) { // Here is the change, but it may be if($age >= 18 && $age < 35) print '<p>Youth Message!</p>'; } else { $age .=$age; } // End of 1st conditional. if ($age >= 35) { print '<p>Generic Message!</p>'; } else { $age .=$age; } // End of 2nd conditional. ?> Link to comment https://forums.phpfreaks.com/topic/204755-got-a-problem-trying-to-get-this-to-work-right/#findComment-1071971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.