Thursday 13 February 2014

More On Error Reporting in php

Error Reporting
Error Reporting
This is a tutorial for Error reporting. Let’s Back to php.ini file(ScreenShot1).

More On Error Reporting in php
Screenshot1
Error Reporting value is E_All, So we are Reporting errors back to our self as we developing. What happen if i want to report errors Strict errors. Now E_Errors Does not Include E_Strict, So i will specify under error_reporting another value E_Strict (ScreenShot2).

error reporting
Screenshot2

error_reporting = E_ALL & E_STRICT


Now this will include errors of run-time notices, enable to have PHP suggest changes to your code which will ensure the best interchangeability and forward compatibility of your code. So basically giving us messages about code itself other then errors that you made be coming across  Now “&” sign is use for including and for not including “~” sign is used. (Screenshot3).

php code errors
Screenshot3

error_reporting = E_All & ~E_NOTICE 

If we don’t wanna Show E_NOTICE types of error we include “~”.This will show all errors, except for notice and coding standards warnings.So Its upto you what level errors you want to display if your codes having errors.If your application is big you can turn onhave a look. Now when u complete your program or applicationon web-server you have to turn error_reporting off
When u complete your program you need to :-

error_reporting=0;

Why the reason being is the errors shows on your pages specially in E_STRICT notices you don’t want to your users or viewers to tell about your errors notices and warnings. For security reasons also u had to turn off. For example if u including file or copying file and there u had errors its shows errors to visitors and they will understand your website structure.So, Best thing is to you put error_reporting=0 when u release your website to web-server to visitors. Now if u had paid hosting you will not have access to php.ini files for that there are some functions have look. What happen if we want to dynamically update error_reporting value inside php (Screenshot4), and (Screenshot5).

php codes error reporting
Screenshot4
error_reporting
Screenshot5
 Code Dynamically update error_reporting value inside php:-

Code Error reporting for E_ALL :-


<?php

error_reporting(0);

echo $var = 'Alex'

$var2 = 'billy';

?>




You can also use functions for writing dynamically update error_reporting value inside php

ini_set function
Code for ini_set function Screenshot6

<?php

ini_set('error_reporting',E_ALL);



echo $var = 'Alex'

$var2 = 'Billy';

?>


This is all About error_reporting how u can put errors for you how can you find errors for visitors.


No comments:

Post a Comment

Thanks For Comment Will get you Soon..

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates