Several minor mistakes that php beginners can easily make

Source: Internet
Author: User
Several minor mistakes that php beginners can easily make
This article lists several minor mistakes that php beginners may make for your reference. 1. the header already sent error usually occurs when you use the HEADER. it may be caused by several reasons.

This article lists several minor mistakes that php beginners may make for your reference.

1. header already sentThis 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 .!

2. variables cannot be transferred between pages.The get, post, and session automatic global variables are disabled in the latest PHP version. therefore, to obtain and submit the 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. ini is changed to reGISter_globals = On). considering compatibility, it is better to force yourself to get familiar with the new writing method.

3. an error occurs when apache2 uses the get method to pass Chinese parameters under Win32.: Test. php? A = Hello & B = you can pass the parameter, which will lead to an internal error. Solution: "test. php? A = ". urlencode (hello)." & B = ". urlencode (you ).............

4. the session in win32 cannot work normally.Php. ini default session. save_path =/tmp this is obviously a configuration in Linux. In win32, php cannot read or write session files, and thus the session cannot be used. you can change it to an absolute path, for example, session. save_path = c: Windows emp

5. email cannot be sent by mail () under Win32Sendmail configured in linux can be sent. In win32, you need to call the smtp server to send an email and modify php. SMTP = ip // ip address of ini is an smtp server without verification (hard to find online) the best solution for sending emails in php is to directly send emails to the recipient's email server using socket instead of forwarding the server.

6. If no password is set for the newly installed MySQL instanceUse update mysql. user set password = "yourpassword" where user = "root" to change the password.

7. display error messagesWhen 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 is assigned a value. 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.

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.