• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with displaying errors

#1
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/johns-jokes.cf/app-welcome/Views/errors/html/error_exception.php:186 Stack trace: #0 /home/john/www/johns-jokes.cf/app-welcome/Views/errors/html/error_exception.php(186): 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:

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

<?php else: 
 
 # START MODIFIED SCRIPT             
 
   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>'
 
       else:
 
         // FORCE (string) WHEN $value == BOOL OR INTEGER
 
         echo htmlspecialchars( (string) $valueENT_SUBSTITUTE'UTF-8'); 
 
       endif
 
     echo '</td></tr>';
 
   endforeach
 
   # END MODIFIED SCRIPT 
 
 endif
?>



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.
CI4 Develop Site - progressing nicely - Thank you Smile
https://johns-jokes.cf/pictures

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.