Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Venkok

  • Rank
  1. Thank you, Larry. Now it's clear. I have another solution for Pursue 3, I feel like Christopher's solution is more straightforward and clean but I use the function which allows having less writing (without duplication "The total cost of driving"...). Can you please say a few wise words about my code? // Check for form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Minimal form validation: if (isset ($_POST['distance'], $_POST['gallon_price'], $_POST['efficiency'], $_POST['average_speed']) && is_numeric($_POST['distance']) && is_numer
  2. Hello! Please explain why to use the constant of an average speed and then let user enter any value of it into the form. Where this value of 65 goes?
  3. Hi! Why do we need this: $gender = 'a'; //create a false value to test against The script works well without it, please explain!
  4. Hello! Please explain to me how gender validations from scripts 2.3 differ from the nested one in script 2.4. I have this in 2.3 (updated with NULL coalescing operator while practicing Pursue section): $gender = $_REQUEST['gender'] ?? NULL; if ($gender == 'M') { $greeting = '<p><strong>Good day, Sir!</strong></p>'; } elseif ($gender == 'F') { $greeting == '<p><strong>Good day, Madam!</strong></p>'; } else { $gender = NULL; echo '<p class="error">Gender must be either "M" or "F"!<
  5. After your new hint, I immediately came up with the solution, which now seems so obvious! Thank you!
  6. Hello! I stuck into this question, please help me to solve it: Rewrite the gender conditional in handle_form.php (Script 2.4) as one conditional instead of two nested ones. Hint: You’ll need to use the AND operator.
  7. Hi to all! This script works identically without ! empty conditional, am I right? if (! empty ($_POST['name']) && ! empty ($_POST['email']) && ! empty ($_POST['comments'])) { } the same as: if (($_POST['name']) && ($_POST['email']) && ($_POST['comments'])) { } Thank you!
  • Create New...