Home > Backend Development > PHP Tutorial > Summary of 14 problems that give PHP beginners a headache_PHP Tutorial

Summary of 14 problems that give PHP beginners a headache_PHP Tutorial

WBOY
Release: 2016-07-21 14:56:14
Original
1022 people have browsed it

1. Variables cannot be passed between pages

The automatic global variables of get, post, and session are turned off in the latest PHP version, so to get the submitted variables from the previous page, use $_GET['foo'], $_POST['foo'], $_SESSION['foo'] to get. Of course, you can also modify the automatic global variables to be on (php.ini is changed to register_globals = On); considering compatibility, it is better to force yourself to become familiar with the new writing method.

2. Using the get method to pass Chinese parameters to apache2 under Win32 will cause an error

test.php?a=Hello&b=Hello

Passing parameters will cause an internal error

Solution: "test.php?a=".urlencode(Hello)."&b=".urlencode(Hello)

......

3. Session under win32 does not work properly

php.ini default session.save_path = /tmp

This is obviously a configuration under Linux. PHP cannot read and write session files under win32, causing the session to be unusable

Just change it to an absolute path, for example session.save_path = c:windowstemp

4. Display error message

When display_errors = On and error_reporting = E_ALL in php.ini, all errors and prompts will be displayed. It is best to turn it on during debugging for error correction. If you use the previous PHP writing method, most of the error messages are about undefined variables. . There will be a prompt when a variable is called before it is assigned a value. The solution is to detect or shield it.

For example, to display $foo, you can if(isset($foo)) echo $foo or echo @$foo

5. Mail() cannot send emails under Win32

Sendmail configured under Linux can be sent. Under win32, you need to call the smtp server to send emails. Modify the SMTP = ip in php.ini //ip is an smtp server without verification function (hard to find on the Internet) , the best solution for sending emails in php is to use socket to send directly to the other party's email server without forwarding the server.

6. If there is no password set for the initial installation of mysql, 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 HEADER. It may be due to several reasons: 1. You PRING or ECHO before using HEADER 2. There is a blank line in front of your current file 3. You may have INCLUDEd a file , this error will also occur if there is a blank line at the end of the file or the output.

8. There is no change after changing php.ini

Restart the web server, such as IIS, Apache, etc., and then the latest settings will be applied

  • Total 2 pages:
  • Previous page
  • 1
  • 2
  • Next page

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364227.htmlTechArticle1. Variables get, post, and session cannot be passed between pages. In the latest PHP version, automatic global variables are turned off. Yes, so to get the submitted variables from the previous page, use $_GET['foo']...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template