PHP Impoved error messaging on pages that fail parsing

Viewed 28

This isn't quite a "fix my code" question, more of a configuration. I'm working with the HTML/Javascript/PHP/MySql stack. I'm a seasoned C#/TSQL developer but fairly new to this stack. I'm finding debugging very frustrating as compliation/parse errors are not shown during development. For example, after making a series of modifications, in one of my PHP libraries I've had the following:

    function sp_AssignNotificationsToUsr($CreateGUID, $UsrID, &$message) // boolean
    // This assigns any notifications with the CreateGUID passed, to the UsrID passed.
    // If successful, returns true, else false.
    // If false is returned, look in $message for an error message.
    {
        try
        {
            $sql = "";
            $sql .= "SET @CreateGUID = " . Str2SQL($CreateGUID) . ";" . PHP_EOL;
            $sql .= "SET @UsrID = " . $UsrID . ";" . PHP_EOL;
            $sql .= "" . PHP_EOL;
            $sql .= "CALL AssignNotificationsToUsr(@CreateGUID, @UsrID);" . PHP_EOL;
            $sql .= "" . PHP_EOL;

            $db = new DB;
            if (!$db->connect()) throw new Exception("Could not connect to database correctly.");           
            $dss = $db->executeMultiQuery2($sql);
            $db->disconnect();
            return true;
        }
        catch (Exception $e)
        {
            $message = $->getMessage();
            ErrorMessageEmail("sprocs.php:sp_AssignNotificationsToUsr", 1, $e);
            return false;
        }
    }

When I run the calling page, it returns empty with no errors. I have already executed the following during the page:

    ini_set('display_startup_errors', 1);
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);

When this occurs (no output, no errors), I then spend time commenting in and out great swathes of code in various files, trying to pin down where the parse error is. In this instance, it turned out to be that:

$message = $->getMessage();

should have been:

$message = $e->getMessage();

I'm used to Visual Studio pointing out parse errors before I even try to run code, which obviously isn't how it works here. I'm using Notepad++ as an editor. Is there some configuration I can use to show compile time errors like this? The same with the client-side Javascript. If it has a parse error it just does nothing with no errors shown. How can I get the errors from the parser shown?

0 Answers
Related