CodeIgniter Forums

Full Version: Problem with displaying errors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have struggled with the ouput from "/application/Views/html/error_exception.php" because the following output is not intuitive Sad

Quote:ErrorException #1

Uncaught TypeError: htmlspecialchars() expects parameter 1 to be string, boolean given in /home/john/www/ Stack trace: #0 /home/john/www/ htmlspecialchars(true, 8, 'UTF-8') #1 /home/john/www/ci2/CodeIgniter4/system/Debug/Exceptions.php(276): include('/home/john/www/...') #2 /home/john/www/ci2/CodeIgniter4/system/Debug/Exceptions.php(153): CodeIgniter\Debug\Exceptions->render(Object(TypeError), 500) #3 [inter

I modified  "html/error_exception.php" and the output is now far more readable:

Argument 2 passed to add() must be of the type integer, string given, called in /home/john/www/ on line 17    
PHP Code:
<?php NEAR Line #190 ?>
<?php if( FALSE ) : ?>
    <?php foreach ($constants['user'] as $key => $value) : ?>
        <td><?= htmlspecialchars($keyENT_IGNORE'UTF-8'?></td>
          <?php if (!is_array($value) && ! is_object($value)) : ?>
            <?= htmlspecialchars $valueENT_SUBSTITUTE'UTF-8'?>
          <?php else: ?>
            <?= '<pre>'.print_r($valuetrue) ; ?>
          <?php endif; ?>
    <?php endforeach; ?>
  <?php # END ORIGINL SCRIPT ?> 

<?php else: 
   foreach ($constants['user'] as $key => $value) : 
     echo '<tr><td>' ;
       echo htmlspecialchars($keyENT_IGNORE'UTF-8');
     echo '</td><td>';
       if is_array($value) || is_object($value)) : 
         echo '<pre>'.print_r($valuetrue) .'</pre>'
         // FORCE (string) WHEN $value == BOOL OR INTEGER
         echo htmlspecialchars( (string) $valueENT_SUBSTITUTE'UTF-8'); 
     echo '</td></tr>';

I also added a missing trailing </pre> where required in other parts of the script.

I would be grateful if someone could check the proposed changes.