What should I do if an error is reported when PHP variables are not declared?

藏色散人
Release: 2023-03-10 18:46:01
Original
2319 people have browsed it

Solution to the error when php variables are not declared: 1. Insert the "ini_set("error_reporting",E_ALL ^ ​​E_NOTICE);" statement at the beginning of php; 2. Modify the configuration of php.ini.

What should I do if an error is reported when PHP variables are not declared?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php variables are not declared. What should I do if an error is reported?

How to prevent undefined php variables from reporting errors?

In the process of php development, we often encounter problems: undefined variable...

The reason for the error is: the variable is not defined

However, according to the official documentation: php Variables do not need to be defined

So this creates a problem. During the development process, if we use undefined variables, bad results will occur. The reason for this problem is the error level of php.

So how to correct this problem?

First method: You can insert a statement at the beginning of php:

ini_set("error_reporting",E_ALL ^ ​​E_NOTICE);

Second Method:

Modify the configuration of php.ini

In line 302 of php.ini error_reporting = E_ALL

Modify it to

error_reporting = E_ALL & ~E_NOTICE and then restart apache2.2

Solution: Modify php.ini

Change: error_reporting = E_ALL

Change to: error_reporting = E_ALL & ~E_NOTICE

If you don’t want any errors to be displayed, modify it directly:

Display_errors = Off

It is recommended to use the first method.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if an error is reported when PHP variables are not declared?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!