PHP Learning 5--Exception Handling

Source: Internet
Author: User

PHP Error type
    • Syntax error
    • Execution-time error
    • Logic error
The generation of exceptions

If XAMPP is installed, the error report can be set in php.ini, and the profile path: C:\xampp\php

You can use Error_reporting (0) To turn off error prompts and report all errors using error_reporting (E_all)

use in INI file; semicolon Comment

Error log

Logging error report logs using the specified file

After the product is put into use, all of the error prompts are usually turned off, as these hints can affect the consumer's experience with the product, and exposing too much information is vulnerable to hacking.

The error message can be saved to a separate text (log file) instead of appearing in the browser.

The default is configured so that you can use Error_log ($msg) to customize the error message in your program

error.php

<?phpecho "Ssdsds"; Error_log ("This is a custom error log message"); >

  

Open File

[06-aug-2018 07:24:24 Europe/berlin] This is a custom error log message [06-aug-2018 07:24:50 Europe/berlin] This is a custom error log message

  

Open the php.ini configuration file

Report all errors in PHP

Set PHP error log address:

Log information logged to the operating system log

Common methods

    • Openlog ($msg, $option, $facility) open log connections, such as Openlog ("PHP", Log_pid,log_user)
    • Syslog ($priority, $msg) generates log messages, such as Syslog (log_warning, "Send custom information to syslog ... ")
    • Closelog () Close log connection

syslog.php

<?phpopenlog ("PHP5", Log_pid,log_user); Syslog (log_warning, "Sending custom information to Syslog"); Closelog (); >

The custom information is recorded in the system log, you can click on the warning, which is the generated information, in the Computer Management Event Viewer Windows log application.

PHP Learning 5--Exception Handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.