Variables in php can be undefined, but if we do not handle errors, an Undefinedvariable error will be prompted when Undefinedvariable is used. I will give you several examples below. PHP error prompt quot; Undefined... variables in php can be Undefined, but if we do not handle errors, an Undefined variable error will be prompted when Undefined variables are used. I will give you several examples below.
PHP error prompt "Undefined variable": the variable is Undefined. if the Notice level prompt is blocked in the ini settings, no prompts will be displayed. however, to ensure program rigor, we try to avoid any obvious program defects such as warnings and errors.
Example 1: The following code in class. Chinese. php has an error "Undefined variable ".
For ($ I = 0; $ I
The correct method should be the following code:
$ Bindata = ''; for ($ I = 0; $ I
Example 2: The following code also has an error "Undefined variable ":
$sl = "zh-CN"; $tl = "en"; function app_out($c,$gbk){ $data = app_get_translate($c,$sl,$tl); $out = str_replace($c,$data,$c); return app_js_out($out,$gbk); }
The correct statement should be:
$ Sl = "zh-CN"; $ tl = "en"; function app_out ($ c, $ gbk) {global $ sl, $ tl; // define the two variables in this function as global variables to use the value $ data = app_get_translate ($ c, $ sl, $ tl) set at the beginning ); $ out = str_replace ($ c, $ data, $ c); return app_js_out ($ out, $ gbk );}
Php does not need to define variables, but what should I do in this case? If you find php. ini in C: WINDOWS, change error_reporting = E_ALL in row 302 of php. ini
Error_reporting = E_ALL &~ E_NOTICE: restart apache2.2.
If you do not want to display any errors, modify display_errors = Off.
If you do not have permission to modify php. ini, you can add it to the php header.
Ini_set ("error_reporting", "E_ALL &~ E_NOTICE ");
Tutorial link:
Reprint at will ~ However, please keep the tutorial address★