How to effectively block PHP warnings and error prompts

Source: Internet
Author: User
Many friends often encounter the following errors when writing PHP:

Many friends often encounter the following errors when writing PHP:
Warning: file_get_contents (/usr/local/tads/htdocs/XXXXXX/src/cache/countLoginnum.txt) [function. file-get-contents]: failed to open stream: No such file or directory in/usr/local/tads/htdocs/XXXXXXX/src/controllers/defaultController. php on line 43

Warning: Cannot modify header information-headers already sent by (output started at/usr/local/tads/htdocs/XXXXXX/src/config/env. php: 5) in/usr/local/taesdk/1.0/phplib3/src/base/core/TMWebResponse. class. php on line 332

Solution: add the following code to the PHP file header to shield the warning error:
 

PHP code
  1. // Put session_star () after session_star ()
  2. Error_reporting (E_ERROR );
  3. Ini_set ("display_errors", "Off ");
  4. // Your php code
  5. ?>

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.