Search the Community
Showing results for tags 'Declaring'.
-
Hello, I've just read the tutorial on how to process a form in PHP, available on this site, and I was wondering if there's a specific reason to declare empty variables (or arrays) at the beginning? I don't understand what is the point of doing so. For example, in the following code, why would the 2sd and 3rd lines be necessary? <?php $errors = []; $name = $email = $message = ''; if (condition) { $errors['name'] = 'alert'; } else { $name = sanitize_input($_POST['name']); if (new_condition, $name) { $errors['name'] = 'new alert'; } }
-
Do you have to Re-Declare a variable to assign it a different Data Type?
- 1 reply
-
- JavaScript
- Variables
-
(and 1 more)
Tagged with: