Alexancho Posted February 22, 2010 Report Share Posted February 22, 2010 I started to learn PHP and am facing to problems now.1. I use <?php error_reporting(E_ALL);?> and don't get any report.2. Cod like this <?php$firstquarter = array(1 => 'January', 'February', 'March');print_r($firstquarter);?> prints all the data in a one line: Array ( [1] => January [2] => February [3] => March )when it must be something like this:Array( [1] => January [2] => February [3] => March) Link to comment Share on other sites More sharing options...
Synook Posted February 22, 2010 Report Share Posted February 22, 2010 1. Well, do you actually have any errors?2. That's because in HTML newlines aren't rendered - you have to use break tags (e.g. through nl2br()) (or you can enclose the text in a tag like <pre>). You can also change the page's content-type to something like text/plain. Link to comment Share on other sites More sharing options...
Alexancho Posted February 22, 2010 Author Report Share Posted February 22, 2010 (edited) 1. Well, do you actually have any errors?Yes, of course. I did errors even in purpose to see them.Actually i can see the errors if i turn on the "display errors" in PHP settings in my WAMP. Edited February 22, 2010 by Alexancho Link to comment Share on other sites More sharing options...
justsomeguy Posted February 23, 2010 Report Share Posted February 23, 2010 You can set display errors yourself in PHP using ini_set:http://www.php.net/manual/en/function.ini-set.php Link to comment Share on other sites More sharing options...
jeffman Posted February 23, 2010 Report Share Posted February 23, 2010 (edited) Remember that if you turn on error reporting in the script you are testing, it will only report runtime errors. Syntax errors (parse errors) will be caught before the script is actually executed, so the statements that turn on error reporting will also not execute. This is what leads to the dreaded "blank screen." Errors like that can be reported only if error reporting is turned on in your settings, or if you include your script in a kind of shell script that has error reporting turned on. I use a thing like this sometimes:test.php <?php error_reporting(E_ALL); ini_set('display_errors', 1); if (!empty($_GET['file'])){ include $_GET['file']; }?> Which I call from my address bar like this:www.me.com/test.php?file=newscript.phpWhere newscript.php is the script I'm evaluating. Included files are parsed at runtime, so this means test.php will execute for certain. Since test.php turns on the error reporting, and is guaranteed to execute, syntax errors in newscript.php will always be reported. Edited February 23, 2010 by Deirdre's Dad Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now