Page 1 of 1

what's this line meaning?

Posted: Thu Aug 12, 2010 11:03 pm
by everydayrun

Code: Select all

<?phpob_start();
$er = error_reporting(0); 
what's the above code meaning?and what it will do?

Re: what's this line meaning?

Posted: Thu Aug 12, 2010 11:42 pm
by internet-solution
it will start output buffer and turn off error reporting

Re: what's this line meaning?

Posted: Thu Aug 12, 2010 11:43 pm
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).

Re: what's this line meaning?

Posted: Thu Aug 12, 2010 11:44 pm
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