Error echo is commonly used in development mode, but many applications forget to turn off this option in the official environment. Error echo can expose a lot of sensitive information, which facilitates the attacker's next attack. It is recommended to turn off this option
display_errors
Error echo, commonly used in development mode, but many applications forget to turn off this option in the formal environment. Error echo can expose a lot of sensitive information, which facilitates the attacker's next attack. It is recommended to turn this option off.
display_errors = On
In the on state, if an error occurs, an error will be reported and an error message will appear.
dispaly_errors = Off
In the off state, if an error occurs, it will prompt: Server error. But no error message will appear.
log_errors
Just use this in a formal environment and record the error information in the log. Just in time to turn off error echo.
For PHP developers, once a product is put into use, the first thing to do is to turn off the display_errors option to avoid being attacked by hackers due to the paths, database connections, data tables and other information disclosed by these errors.
After a product is put into use, there will inevitably be error messages, so how to record this information that is very useful to developers?
Just turn on PHP's log_errors. By default, it is recorded to the log file of the WEB server, such as Apache's error.log file.
Of course, you can also record error logs to specified files.
# vim /etc/php.inidisplay_errors = Off
log_errors = On
error_log = /var/log/php-error.log
You can also set error_log = syslog to record these error messages to the operating system log inside.
display_errors = Off //display in Chinese means display, so display_error=off means not displaying errors!
error_reporting sets the level of error message reporting
2047 I remember it should be E_ALL.
php.ini
There are many configuration settings in the file. You should have already set up your php.ini file and placed it in the appropriate directory, just like installing PHP and Apache on Linux
2 (see Resources). There are two configuration variables that you should be aware of when debugging PHP applications. The following are these two variables and their default values:
display_errors = Off //Turn off all error messages. When it is ON, all error messages are displayed.
error_reporting = E_ALL
E_ALL covers everything from bad coding practices to harmless tips to errors. E_ALL is a bit too detailed for the development process, because it also displays prompts on the screen for small things (such as variables not being initialized), which will mess up the browser's output
So it is not recommended to use 2047, it is best to change the default value to: error_reporting = E_ALL & ~E_NOTICE
Solution to the failure of display_errors = Off in PHP.ini
Problem:
Display_errors = Off has been clearly set in the PHP setting file php.ini, but during operation, error messages still appear on the web page.
Solution:
Check log_errors=
On, according to the official statement, when this log_errors is set to On, then the error_log file must be specified. If it is not specified or the specified file does not have permission to write, then the error will still occur.
Out of the normal output channel, this also invalidates the specified Off of display_errors, and the error message is still printed. So log_errors =
Off, the problem is solved.
It is often seen that error_reporting (7) means: setting the level of error message reporting.
value constant
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
64 E_COMPILE_ERROR
128 E_COMPILE_WARNING
256 E_USER_ ERROR
512 E_USER_WARNING
1024 E_USER_NOTICE
2047 E_ALL
2048 E_STRICT
However, 7=1+2+ 4
It means 1 E_ERROR 2 E_WARNING 4 E_PARSE
//Disable error reporting
error_reporting(0);
//Report runtime errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting all errors
error_reporting(E_ALL);
?>
The above introduces the PHP error message configuration, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Effective methods to prevent session fixed attacks include: 1. Regenerate the session ID after the user logs in; 2. Use a secure session ID generation algorithm; 3. Implement the session timeout mechanism; 4. Encrypt session data using HTTPS. These measures can ensure that the application is indestructible when facing session fixed attacks.

Implementing session-free authentication can be achieved by using JSONWebTokens (JWT), a token-based authentication system where all necessary information is stored in the token without server-side session storage. 1) Use JWT to generate and verify tokens, 2) Ensure that HTTPS is used to prevent tokens from being intercepted, 3) Securely store tokens on the client side, 4) Verify tokens on the server side to prevent tampering, 5) Implement token revocation mechanisms, such as using short-term access tokens and long-term refresh tokens.

The security risks of PHP sessions mainly include session hijacking, session fixation, session prediction and session poisoning. 1. Session hijacking can be prevented by using HTTPS and protecting cookies. 2. Session fixation can be avoided by regenerating the session ID before the user logs in. 3. Session prediction needs to ensure the randomness and unpredictability of session IDs. 4. Session poisoning can be prevented by verifying and filtering session data.

To destroy a PHP session, you need to start the session first, then clear the data and destroy the session file. 1. Use session_start() to start the session. 2. Use session_unset() to clear the session data. 3. Finally, use session_destroy() to destroy the session file to ensure data security and resource release.

How to change the default session saving path of PHP? It can be achieved through the following steps: use session_save_path('/var/www/sessions');session_start(); in PHP scripts to set the session saving path. Set session.save_path="/var/www/sessions" in the php.ini file to change the session saving path globally. Use Memcached or Redis to store session data, such as ini_set('session.save_handler','memcached'); ini_set(

TomodifydatainaPHPsession,startthesessionwithsession_start(),thenuse$_SESSIONtoset,modify,orremovevariables.1)Startthesession.2)Setormodifysessionvariablesusing$_SESSION.3)Removevariableswithunset().4)Clearallvariableswithsession_unset().5)Destroythe

Arrays can be stored in PHP sessions. 1. Start the session and use session_start(). 2. Create an array and store it in $_SESSION. 3. Retrieve the array through $_SESSION. 4. Optimize session data to improve performance.

PHP session garbage collection is triggered through a probability mechanism to clean up expired session data. 1) Set the trigger probability and session life cycle in the configuration file; 2) You can use cron tasks to optimize high-load applications; 3) You need to balance the garbage collection frequency and performance to avoid data loss.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
