[1] variables cannot be transferred between pages.
Get, post, and session in the latestPHPIn the version, automatic global variables are disabled. To obtain and submit the variables from the previous page, use $ _ Get ['foo'], $ _ post ['foo'], $ _ session ['foo'] to obtain
Of course, you can also change the automatic global variable to on (PHP. INI is changed to register_globals = on). Considering compatibility, it is better to force yourself to get familiar with the new writing method.
[2] an error occurs when apache2 uses the get method to pass Chinese parameters under Win32.
Test. php? A = Hello & B = You
Passing parameters will cause an internal error.
Solution: "test. php? A = ". urlencode (Hello)." & B = ". urlencode (you can also)
.............
[3] The session under Win32 does not work normally
PHP. ini default session. save_path =/tmp
This is obviouslyLinuxUnder the configuration, Win32 PHP cannot read and write session files, resulting in session failure
Change it to an absolute path, for example, session. save_path = c: \ windows \ temp.
[4] displaying error messages
When PHP. when display_errors = on and error_reporting = e_all of INI, all errors and prompts are displayed. It is best to enable this function during debugging for error correction, if you use PHP to write errors, most of them are about undefined variables. A prompt is displayed before the variable value is assigned. The solution is to detect or block the variable.
For example, if $ foo is displayed, you can use if (isset ($ Foo) echo $ Foo or ECHO @ $ Foo.
[5] Win32 mail () cannot send email
Sendmail configured in Linux can be sent. in Win32, you need to call the SMTP server to send emails.
Modify SMTP = IP address of PHP. ini // ip address is an SMTP server without verification function (it is hard to find it online)
Best Solution for sending emails in PHPMethodIt uses Socket to send directly to the recipient's email server without forwarding the server.
[6] initial installationMySQLIf no password is set, use
Update mysql. User SET Password = "yourpassword" where user = "root"
Change Password
[7] header already sent string 4
This error usually occurs when you use the header. It may be due to several reasons: 1. You Pring or echo before using the header. 2. you have a blank line before the current file. 3. you may include a file. This error may also occur if there are blank lines at the end of the file or the output .!
[8] PHP. INI has not changed.
Restart the web server, such as IIS,ApacheWait until the latest settings are applied.
[9] PHP installation on 2003
Php4isapi. dll of PhP4 seems to be in conflict with 2003. It can only be installed in CGI Mode.
Step 1: first install php-4.2.3-installer.exein www.php.net. You can also find the latest version. Before installing php-4.2.3-installer.exe, ensure that your iis6.0 is started and accessible. After installation, go to the default website --> application configuration
Step 2: click Web Service Extension> Create web service extension.
Step 3: add the extension --> PHP
Step 4: Find the php.exe path and add it.
Step 5: OK!
Step 6: select the PHP service extension and click Allow.
[10]
Sometimes the SQL statement does not work.DatabaseOperation failed
The simplest debugging method is echo the SQL statement to see if the variable value can be obtained
[11] differences between include and require
There is no big difference between the two. If the file to be included does not exist, include prompts notice, and then continues to execute the following statement. Require prompts a fatal error and exits.
According to my tests, on the Win32 platform, they are all included first and then executed. Therefore, it is recommended that there be no include or require statements in the contained files, which will cause directory confusion. Maybe * Nux is different. It hasn't been tested yet.
If you do not want to include a file multiple times, you can use include_once or require_once # To Read and Write document data.
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] differences between isset () and empty ()
Both are used to test variables.
However, isset () is used to test whether a variable is assigned a value, while empty () is used to test whether a variable that has been assigned a value is null.
If a variable is not assigned a value, it is allowed to reference it in PHP, but there will be a notice prompt
If a variable is assigned a null value, $ Foo = "" or $ Foo = 0 or $ Foo = false, empty ($ Foo) returns true, isset ($ Foo) returns the true value, that is, the null value will not cancel a variable.
To cancel a variable, you can use unset ($ Foo) or $ Foo = NULL.
[13]MySQLThe query statement contains keywords.
When PHP queries MySQL, sometimes the MySQL table name or column name has a keyword
At this time, the query will have an error. For example, if the table name is order, an error occurs during query.
The simple method is to add '[tab top] to the table name or column name in the SQL statement to differentiate it.
For example, select * From 'order'
[14] how to upload multiple files at a time through the HTTP protocol
There are two ways to implement the same method. Specific procedures also need to be designed by yourself
1. Set multiple file input boxes in form and name them using arrays, as shown below:
<Form action = "" method = post>
<Input type = file name = usefile []>
<Input type = file name = usefile []>
<Input type = file name = usefile []>
</Form>
In this way, perform the following tests on the server side:
Echo "<PRE> ";
Print_r ($ _ files );
Echo "</PRE> ";
1. Set multiple file input boxes in form with different names, as shown below:
<Form action = "" method = post>
<Input type = file name = usefile_a>
<Input type = file name = usefile_ B>
<Input type = file name = usefile_c>
</Form>
Perform the same test on the server:
Echo "<PRE> ";
Print_r ($ _ files );
Echo "</PRE> ";