what's this line meaning?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
everydayrun
Forum Commoner
Posts: 51
Joined: Wed Jan 20, 2010 1:30 am

what's this line meaning?

Post by everydayrun »

Code: Select all

<?phpob_start();
$er = error_reporting(0); 
what's the above code meaning?and what it will do?
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: what's this line meaning?

Post by internet-solution »

it will start output buffer and turn off error reporting
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: what's this line meaning?

Post by McInfo »

The long explanation:

Code: Select all

<?php // This opening tag signals the PHP parser that PHP code follows.

ob_start(); // This statement calls a function named ob_start that starts output buffering, which collects output data generated by the script into a buffer and prevents it from being displayed immediately.

$er = error_reporting(0); // This statement calls a function named error_reporting that affects a PHP configuration setting that deals with how errors are handled. Here, an argument of 0 (zero) is passed to the function, which will cause error reporting to be disabled. The function returns an integer value that represents the old error reporting level. The = sign causes the value on the right (the integer returned by the function) to be assigned to a variable on the left (in this case, $er).
Last edited by McInfo on Thu Aug 12, 2010 11:44 pm, edited 1 time in total.
User avatar
iijb
Forum Commoner
Posts: 43
Joined: Wed Nov 26, 2008 11:34 pm

Re: what's this line meaning?

Post by iijb »

Hi
The code line means
Turn off all error reporting
in php. Php has many levels of error reporting. These can be done in two ways. First is, use the option in the php.ini file. If you gone through the php.ini file you can see the configuration of error reporting there. Second is, use the function error_reporting() in your php script. Which is what you have done in your code. For a developing environment, turn off error reporting is not a good method to follow. You have to turn on all error reporting so that you can easily debug your code.

Please go through this http://php.net/manual/en/function.error-reporting.php link for further reading.

Regards
iijb
Post Reply