Make PHP beginner Headache 14 Big Summary _php Tutorial

Source: Internet
Author: User
Tags flock urlencode
1. Variables cannot be passed between pages
Get,post,session Automatic global variables are turned off in the latest PHP version, so the variables to be submitted from the previous page are obtained using $_get[' foo '],$_post[' foo '],$_session[' foo '. Of course, you can also modify the automatic global variable to ON (php.ini to register_globals = on), or it is better to force yourself to be familiar with the new wording, considering compatibility.
2, Win32 apache2 using the Get method to pass Chinese parameters will be an error
test.php?a= Hello &b= You
Passing parameters can cause an internal error
Workaround: "Test.php?a=". UrlEncode (Hello). " &b= ". UrlEncode (you're good too)
......
3, Win32 under the session does not work properly
php.ini default Session.save_path =/tmp
This is obviously the configuration under Linux, Win32 PHP can not read and write session files resulting in the session can not be used
Change it to an absolute path, for example Session.save_path = C:\Windows\Temp
4. Display error message
When php.ini display_errors = on and error_reporting = E_all, all errors and hints are displayed, preferably open for error correction when debugging, if you use the previous PHP notation, most of the error information is about undefined variables. Variables are called before they are assigned, and the solution is to detect or block.
For example, $foo can be displayed, if (Isset ($foo)) echo $foo or echo @ $foo
5, Win32 Mail () cannot send email
Configured under Linux SendMail can be sent, in Win32 need to call the SMTP server to send e-mail, modify php.ini SMTP = IP//ip is not with authentication features of the SMTP server (difficult to find online), PHP the best way to send mail is to send the socket directly to the other email server instead of forwarding the server.
6, the initial installation of MySQL if you do not set a password, you should use
Update Mysql.user set password= "YourPassword" where user= "root"
Change Password
7. Header already sent
This error usually occurs when you use the header, he may be several reasons: 1, you are using the header before the Pring or Echo 2. You have a blank line 3 in front of your current file. You may include a file with a blank line or output at the end of the file.
8. No changes after changing php.ini
Restart the Web server, such as Iis,apache and so on, before applying the latest settings
9, PHP installed on the 2003 (ISAPI installation method request expert advice)
PHP4 's php4isapi.dll seems to be in conflict with 2003 and can only be installed in CGI mode:
Step one, first www.php.net down in one installation process
10, sometimes the SQL statement does not work, the database operation failed
The easiest way to debug, echo the SQL, to see if the value of the variable can be obtained.
11. The difference between include and require
There is not much difference, if the file to be included does not exist, include prompt notice, and then continue to execute the following statement, require prompt fatal error and exit, according to my test, Win32 platform they are first included after execution, Therefore, it is best not to have include or require statements in the included files, which can cause directory confusion. Maybe *nux under different circumstances, not yet tested.
If a file does not want to be included multiple times can be read using include_once or require_once##, write the document data:
Copy CodeThe code is as follows:
function R ($file _name) {
$filenum = @fopen ($file _name, "R");
@flock ($filenum, lock_sh);
$file _data= @fread ($filenum, FileSize ($file _name));
@fclose ($filenum);
return $file _data;
}
function W ($file _name, $data, $method = "W") {
$filenum = @fopen ($file _name, $method);
Flock ($filenum, LOCK_EX);
$file _data=fwrite ($filenum, $data);
Fclose ($filenum);
return $file _data;
}

12. The difference between isset () and empty ()
Both are used to test variables.
But Isset () is a test for whether a variable is assigned, and empty () tests whether a variable that has already been assigned is empty. If a variable is not assigned the reference is allowed in PHP, but there is a notice hint. If a variable is assigned a null value, $foo = "" or $foo=0 or $foo =false, then empty ($foo) returns True, Isset ($foo) also returns true, meaning that the null value does not unregister a variable.
To unregister a variable, you can use Unset ($foo) or $foo=null.
13. MySQL Query statement contains keywords
When PHP queries MySQL, sometimes MySQL table name or column name will have a keyword. The query will have errors at this time. For example, the table name is Order and an error occurs when querying. The simple way is to distinguish the table name or column name in the SQL statement with the ' [Tab key].
For example, select * from ' order '.
14. How to upload multiple files at once via HTTP protocol
There are two ideas that are two implementations of the same method. Specific procedures also need to design their own:
1. Set multiple file input boxes in the form and name them with an array, as follows:

In this way, the following tests are done on the server side
echo "


echo "
";
2. Set multiple file input boxes in the form, but with different names, as follows:

Do the same test on the server side:
echo "


echo "
";
Order
I am pretending to be: Php-4.2.3-installer.exe, you can also go to the latest version, before installing Php-4.2.3-installer.exe ensure that your IIS6.0 boot up and be able to access. After installation, in the default website---application configuration;
Step Two: Click Web Service Extensions--new Web service extensions;
Step three: Extension-->php, then add;
Step four: Find the path to php.exe add up;
Step five: OK to do it;
Step six: Select PHP's service extensions, then click Allow.

http://www.bkjia.com/PHPjc/319595.html www.bkjia.com true http://www.bkjia.com/PHPjc/319595.html techarticle 1, the page can not pass the variable get,post,session in the latest PHP version of the automatic global variable is closed, so to get from the previous page to submit the variable to use $_get[' foo ' ...

  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.