Turn from: http://echoright.blog.51cto.com/151903/495578
Recently in the process of writing PHP to find PHP prompts PHP Notice: ........ The words, although this is just PHP hints content, and no big impact, but for security and aesthetic considerations, the younger brother still want to remove this thing.
So, how to do it.
Carry out Baidu, directly copy, paste PHP Notice: The results of such search, generally there are two situations:
One, direct to a: Error_reporting=e_all&~e_notice, make you do not know what meaning.
Two
1. Change the error_reporting in the php.ini file
To
Error_reporting=e_all&~e_notice
If you can't manipulate php.ini files, you can use the following methods to implement
2. Add the following code to the page where you want to prevent notice error prompts
* All errors except E_notice *
Error_reporting (e_all ^ e_notice);
Hopefully the above code will solve your problem.
This is okay, let you know how. Open php.ini,ctrl+f Find error_reporting, put the above Ctrl + +, browse their own web page, eh, really do not show PHP notice, at this time is really grateful to the eldest brother Ah, finally help us these rookie to solve the problem.
But don't rush off php.ini, let's take a good look at our php.ini:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error_reporting is a bit-field. Or each number up to get desired error
; Reporting level
; E_all-all errors and warnings (doesn ' t include E_strict)
; E_error-fatal Run-time Errors
; E_recoverable_error-almost Fatal Run-time Errors
; E_warning-run-time warnings (non-fatal errors)
; E_parse-compile-time PARSE Errors
; E_notice-run-time notices (are warnings which often result
; From a bugs in your code, but it's possible that it was
; Intentional (e.g., using an uninitialized variable and
; Relying on the fact it ' s automatically initialized
; Empty string)
; E_strict-run-time notices, enable to have PHP suggest changes
; To your code which would ensure the best interoperability
; And forward compatibility of your code
; E_core_error-fatal errors that occur during PHP ' s initial startup
; E_core_warning-warnings (non-fatal errors) that occur during PHP ' s
; Initial startup
; E_compile_error-fatal Compile-time Errors
; E_compile_warning-compile-time warnings (non-fatal errors)
; e_user_error-user-generated ERROR Message
; e_user_warning-user-generated WARNING Message
; e_user_notice-user-generated NOTICE Message
;
; Examples:
;
; -Show all errors, except for notices and coding standards warnings
;
; error_reporting = E_all & ~e_notice
;
; -Show all errors, except for notices
;
; error_reporting = e_all & ~e_notice | E_strict
;
; -Show Only errors
;
; error_reporting = e_compile_error| e_recoverable_error| e_error| E_core_error
;
; -Show all errors, except coding standards warnings
;
error_reporting = E_all
Although it is in English, but so a few English words, it should be difficult to pour us.
After reading, you will find that the search out of the solution seems not good, but should do so:
get rid of; error_reporting = E_all & ~e_notice This sentence is comprehensive;
This is simpler than the search solution, and it also guarantees the integrity of the php.ini.
Now, let's take a look at the level of error reporting in the Web page.
Take out your PHP manual, index->error_reporting, see it.
The error_reporting () function sets the error_reporting directive at runtime. PHP has many levels of errors, the using this function sets the "Level for" duration (runtime) of your script.
Parameters
Level
The new error_reporting level. It takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for future. As error levels are added, the range of integers increases, so older integer-based error levels'll not always behave as Expected.
The available error level constants are listed below. The actual meanings of these error levels are described in the predefined constants.
Table 82.error_reporting () level constants and bit values
Value constant
1 E_error
2 e_warning
4 E_parse
8 E_notice
E_core_error
E_core_warning
E_compile_error
128 E_compile_warning
256 E_user_error
E_user_warning
1024 E_user_notice
2047 E_all
2048 e_strict
4096 E_recoverable_error
return value
Returns the old error_reporting level.
Example
Example 543.error_reporting () examples
Copy to Clipboard
<?php
Turn off all Error reporting
error_reporting (0);
Errors Simple Running
Error_reporting (E_error | e_warning | E_parse);
Reporting E_notice can be good too (to) uninitialized
Variables or catch variable name misspellings ...)
Error_reporting (E_error | e_warning | E_parse | E_notice);
All errors except E_notice
This is the default value set in PHP.ini
Error_reporting (e_all ^ e_notice);
All PHP errors (bitwise/May is used in PHP 3)
Error_reporting (E_all);
Same as error_reporting (E_all);
Ini_set (' error_reporting ', e_all);
?>
Again English, but also simple, look at this example will know how to do it.