Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home PHP PHP display all errors and warnings

PHP display all errors and warnings

Many website hosting provider/isp has turned off the display errors setting/feature in the php.ini file. This is making your websites more secure and protect your websites from harm.

However, you really need to know what problem with your php script while debugging your code. We have 2 ways to face with the issue:

1. Changing your display_errors setting in the php.ini file:

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; It's recommended that errors be logged on production servers rather than
; having the errors sent to STDOUT.
; Possible Values:
;   Off = Do not display any errors
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On

; This directive controls whether or not and where PHP will output errors, ; notices and warnings too. Error output is very useful during development, but ; it could be very dangerous in production environments. Depending on the code ; which is triggering the error, sensitive information could potentially leak ; out of your application such as database usernames and passwords or worse. ; It's recommended that errors be logged on production servers rather than ; having the errors sent to STDOUT. ; Possible Values: ; Off = Do not display any errors ; stderr = Display errors to STDERR (affects only CGI/CLI binaries!) ; On or stdout = Display errors to STDOUT ; Default Value: On ; Development Value: On ; Production Value: Off ; http://php.net/display-errors display_errors = On

But the display_errors setting should always Off on production environment to protect your website from attackers or bad guys.

Or if you are on shared hosting environment and of course, you do not have permission to change the display_errors setting so you need to think about another solution.

2. Using PHP ini_set function to turn the display_errors setting on

<?php
	ini_set('display_errors', 1);
	ini_set('log_errors', 1);
	ini_set('error_log', dirname(__FILE__) . '/php_error_log.txt');
	error_reporting(E_ALL);
?>

<?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/php_error_log.txt'); error_reporting(E_ALL); ?>

By putting the php script above at the very beginning of your php file, it will overwrite your current display_errors setting and your errors or warnings should be shown. The script above also enable to log the errors/warnings and save them somewhere on your server.

Mar 6, 2011Hoan Huynh
PHP check if folder exists then create folderMySql backup database with gzip compression
You Might Also Like:
  • How To Save PHP Error Log To File In IIS
  • Display User Current Location On Google Map
  • How To Track Website With Multiple Google Analytisc Accounts
  • JavaScript Display Leaving Confirm Box Leave This Page Or Stay On This Page
  • Display Site Down Or Maintenance Message In ASP.NET Web Application
  • PHP Error Log File Location
  • Get Image Width Height With JQuery And JavaScript
  • Jquery checkbox checked
  • Differences Between .NET Framework 4.0 And Earlier Releases
  • xcode change iphone app display name
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

11 years ago PHPdisplay_errors, error_log, error_reporting, ini_set, log_errors, php.ini305
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,455 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,836 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,652 views
JQuery Allow only numeric characters or only alphabet characters in textbox
14,986 views
C# Read Json From URL And Parse/Deserialize Json
11,719 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development