Advanced PHP |
![](images/vline.gif) |
2024-07-27 |
![](images/blank.gif) |
![](images/back.gif) |
![](images/blank.gif)
2 |
![](images/next.gif) |
![](images/blank.gif) |
Watch for uninitialized variables
<?php
if($user=='rasmus') {
$ok = true;
}
if($ok) {
echo "$user logged in";
}
?>
Catch these by setting the error_reporting level to E_ALL.
The above script would generate this warning (assuming $user is set):
Warning: Undefined variable: ok in script.php on line 6
You can of course also turn off register_globals, but that addresses the symptom
rather than the problem.