HazardBoy Posted April 1, 2014 Share Posted April 1, 2014 I saw some people having issues with php and don't know what is wrong. And I believe that php tells you where it hurts just like JavaScript. if something is not working and you can't see why. Make sure you have error reporting on. :) <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); I also use print_r() and var_dump(); to see if print is reach and data is there. What else is there to debug php and track errors? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 1, 2014 Share Posted April 1, 2014 If we are on about PHP, generally the framework at hand handles the errors, however using PHP and JS, I have the following method. Javascript $("form").on("submit", function(e) { e.preventDefault(); var submitButton = $(this).closest('form').find(':submit'); var form = $(this); if(submitButton.hasClass('bconfirm')) { bootbox.confirm(submitButton.data('box'), function(result) { if(result === true) lib.submit(form); }) } else { lib.submit(form); } }); PHP $std = new \StdClass(); $std->alert = $db->error(); And finally on the ajax request to submit my form if(("alert" in data)) { bootbox.alert(data.alert); console.log('Data alert'); } Basically PHP has a database error -> The main module catches it -> throws out a json response -> javascript displays it in a pretty format Quote Link to comment Share on other sites More sharing options...
BlackScorp Posted April 1, 2014 Share Posted April 1, 2014 What else is there to debug php and track errors? well you can install xdebug and setup breakpoints into your script inside IDE and then track you variables. also there exists FirePHP which allows you to display you values inside FireBug extension insdead on the page. also there are PHP/Apache logfiles which are often ignored Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.