There are several reasons why blank pages may be created in PHP programming:
1, logic error
logic error is the most difficult to exclude, on the surface, perhaps the code is legal, is formal, can be run but not expected. Why, then? Perhaps the writer is not comprehensive enough, after all, people are people, computers are computers, computers can not be completely according to People's thinking to run the script. Here, I tell you a better debugging method is to use the annotation symbol "* * * *", comment out some code, observe the operation. To completely eliminate logic errors, no patience is no good, so to calm down, do not worry.
2, behavior undefined
look at the following code:
<?php
$action = $_get[' id '];
if ($action = = ")
$action = 1;
if ($action = = 1) {
echo ("/$action ' s value is 1");
} else if ($action = = 2) {
echo ("/$action ' s value is 2");
}
?>
This code is very clear, that is, if the $action variable is empty, set it to 1, and then judge the value of the $action variable to make a different event. Of course, if $action is neither equal to 1 nor equal to 2, what does PHP do?? Nothing will be done, so there will be a blank page. Knowing the reason, the solution is easy. The solution to this problem, very simple, in the If module after adding an else can be, print some information.
3, syntax error
you may ask, if there is a grammatical error, the general will have the wrong hint, how can it be blank? Of course, this is only a few individual phenomena, in some home space (such as China's free Space Network), if you write PHP syntax errors, it will not have any hint. The solution is also very easy, before uploading the file in the local test, find the wrong code to correct. (www.3lian.com)
4. Misuse of error shielding @
The
error suppressor "@" is often used in places where errors can occur, but the use of a suppressor is too much or is not a good time, and can also lead to white space to avoid it, to see the following two PHP script:
test1.php
<?php
@include ("test2.php");
Echo ($var);
?>
test2.php
<?php
$var = "Hi"//This line of code has errors, no semicolons
$var 1 = "Hello"//ditto
?>
run test1 to see, the result produced a blank page. Correcting is also very simple, you can remove the suppressors in front of the include function, or correct the errors in the test2.php file.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.