PHP beginners headache summary and analysis _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Summary and Analysis of PHP headaches for beginners. Php (as the mainstream development language) for beginners! [1] The get, post, and session variables cannot be passed between pages. in the latest php (as the mainstream development language) version, php (as the mainstream development language) summary of headaches for beginners!
  
[1] The get, post, and session variables cannot be passed between pages. in the latest php (as the mainstream development language) version, automatic global variables are disabled, to obtain the submitted variables from the previous page, use $ _ GET [foo], $ _ POST [foo], $ _ SESSION [foo ].
Of course, you can also change the automatic global variable to On (php (as the mainstream development language). change ini to register_globals = On). considering compatibility, it is better to force yourself to get familiar with the new writing method.
  
[2] Win32 apache (the most popular WEB server platform on the Unix platform) 2. an error occurred when passing Chinese parameters using the get method
Test. php (as the mainstream development language )? A = Hello & B = you
Passing parameters will cause an internal error.
Solution: "test. php (as the mainstream development language )? A = ". urlencode (hello)." & B = ". urlencode (you can also)
  
[3] The session under win32 does not work normally
Php (as the mainstream development language). ini Default session. save_path =/tmp
This is obviously a configuration in linux. In win32, php (as the current mainstream development language) cannot read or write session files, leading to session unavailability.
Change it to an absolute path, for example, session. save_path = c: windowsemp.
  
[4] displaying error messages
When php (as the mainstream development language ). when display_errors = On and error_reporting = E_ALL of ini, all errors and prompts are displayed. it is best to enable the error correction during debugging. if you use php (as the mainstream development language) most of the written error messages 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 php (as the mainstream development language). SMTP = ip address of ini // ip address is an smtp server without verification function (it is hard to find it online)
The best solution for sending emails to php (as the mainstream development language) is to directly send emails to the recipient's email server using socket instead of forwarding servers.
  
[6] If no password is set for the newly installed MySQL (the best combination with PHP), use
Update MySQL (the best combination with PHP). user set password = "yourpassword" where user = "root"
Change password
  
[7] header already sent
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 (as the mainstream development language). ini has not changed.
Restart the web server, such as iis (Microsoft's WEB server platform) and apache (the most popular WEB server platform on Unix) before applying the latest settings.
  
[9] install php on 2003 (as the mainstream development language) (for how to install ISAPI, please advise)
Php (as the mainstream development language) 4 php (as the mainstream development language) 4isapi. dll seems to be in conflict with 2003. it can only be installed in cgi (not many people are using it now) mode.
Step 1: First www. php (as the mainstream development language ). net in an installer, I installed it: before begin, make sure that your iis (Microsoft WEB server platform) 6.0 is started and can be accessed. After installation, go to the default website --> Application Configuration
Step 2: Click web service extension> Create web service extension.
Step 3: extension --> php (as the current mainstream development language), and then add
Step 4: Find the PHP (add the path of the current development language cmd.exe.
Step 5: OK!
Step 6: select the service extension of php (as the current mainstream development language) and click allow.
  
[10] sometimes SQL statements do not work and database operations fail.
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 "){

Http://www.bkjia.com/PHPjc/508613.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/508613.htmlTechArticlephp (as the current mainstream development language) beginners headache summary! [1] The get, post, and session variables cannot be passed between pages in the latest php (as the mainstream development language) version...

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.