Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: How do I get PHP errors to display? #10174
    blankpeter
    Participant

    In order to display a parse error, instead of setting display_errors in php.ini you can use a trick: use include.

    Here are three pieces of code:

    File: tst1.php

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
    // Missing " and ;
    echo "Testing
    

    When running this file directly, it will show nothing, given display_errors is set to 0 in php.ini.

    Now, try this:

    File: tst2.php

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
    include ("tst3.php");
    

    File: tst3.php

    <?php
    // Missing " and ;
    echo "Testing
    

    Now run tst2.php which sets the error reporting, and then include tst3. You will see:

    Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in tst3.php on line 4

Viewing 1 post (of 1 total)