[Special Summer Sale] 40% OFF All Magento 2 Themes

Cart

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: PHP Settings to ignore the WordPress error #10655
    ken-lee
    Participant

    Errors should normally be good for telling you something went wrong

    But if you really want, due to some special purposes, to hide Php errors in WP, then

    Open Your wp-config. php File.

    Replace the Debug Lines. Replace the existing lines with the following code snippet:

    ini_set('display_errors','Off'); 
    ini_set('error_reporting', E_ALL ); 
    define('WP_DEBUG', false); 
    define('WP_DEBUG_DISPLAY', false);
    

    Save and Upload.

    Alternatively, if you can access the php.ini file, then use the following line (restart your httpd after changing the ini file):

    display_errors = On
    
    in reply to: PHP DOMDocument ignores first table's closing tag #10657
    ken-lee
    Participant

    Enclose your $html with <body> and </body>

    Revised Code (Note: I commented out the $stream lines)

    <?php
    $html = <<<HTML
    <body>
    <table>
    <tr><td>A</td><td>Rose</td></tr>
    </table>
    
    <h1>Leave me behind</h1>
    
    <table>
    <tr><td>By</td><td>Any</td></tr>
    </table>
    
    <table>
    <tr><td>Other</td><td>Name</td></tr>
    </table>
    </body>
    HTML;
    
    $dom = new \DOMDocument();
    $dom->loadHTML($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
    
    $tables = $dom->getElementsByTagName('table');
    // $stream = \fopen('php://output', 'w+');
    
    for ($i = 0; $i < $tables->length; ++$i) {
        $rows = $tables->item($i)->getElementsByTagName('tr');
    
        for ($j = 0; $j < $rows->length; ++$j) {
            echo trim($rows->item($j)->nodeValue) . "<br><br>";
        }
    }
    
    // fclose($stream);
    ?>
    

    Alternatively, change

    $dom->loadHTML($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
    

    to

    $dom->loadHTML($html, LIBXML_HTML_NODEFDTD);
    
Viewing 2 posts - 1 through 2 (of 2 total)