return $output; } // All are true echo is_exact(0, false); echo is_exact(4, true); echo is_exact(0, "0"); echo is_exact(0, ""); echo is_exact(0, "a"); echo is_exact("1", "01"); echo is_exact("", null); echo is_exact(3, "3 dogs"); echo is_exact(100, "1e2"); echo is_exact(100, 100.0); echo is_exact("abc", true); echo is_exact("123", " 123"); echo is_exact("123", "+0123"); ?> <?php /* # Type juggling PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which the variable is used. That is to say, if a string value is assigned to variable $var, $var becomes a string. If an integer value is then assigned to $var, it becomes an integer. # Type juggling during comparisons - string vs null : converts to ""
} else { $user_email = htmlspecialchars($_POST['user_email']); $errors[] = "Please enter a valid email address"; } } else { $user_email = ""; $errors[] = "Please enter an email address"; } // check for presence of a password if (has_presence($_POST['user_password'])) { // make sure its at least 7 characters long if (has_min_length($_POST['user_password'], 7)) { // check for presence of a conf_password if (has_presence($_POST['conf_password'])) { // compare the two password for exactness if (is_exact($_POST['user_password'], $_POST['conf_password'])) { // passwords match $user_password = htmlspecialchars($_POST['conf_password']); $conf_password = htmlspecialchars($_POST['conf_password']); // hash protect password $hash_password = password_hash($user_password, PASSWORD_DEFAULT); $user_data['user_password'] = $hash_password; } else { $user_password = ""; $conf_password = ""; $errors[] = "Your passwords didn't match"; } } else { $user_password = htmlspecialchars($_POST['user_password']); $conf_password = ""; $errors[] = "Please confirm your password";