mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Made debug() output html-safe strings by default.
This commit is contained in:
parent
33d2f9a6ed
commit
e9907cb9da
1 changed files with 7 additions and 3 deletions
|
@ -85,12 +85,12 @@
|
|||
* Only runs if debug level is greater than zero.
|
||||
*
|
||||
* @param boolean $var Variable to show debug information for.
|
||||
* @param boolean $showHtml If set to true, the method prints the debug data in a screen-friendly way.
|
||||
* @param boolean $showHtml If set to true, the method prints the debug data in a browser-friendly way.
|
||||
* @param boolean $showFrom If set to true, the method prints from where the function was called.
|
||||
* @link http://book.cakephp.org/view/1190/Basic-Debugging
|
||||
* @link http://book.cakephp.org/view/1128/debug
|
||||
*/
|
||||
function debug($var = false, $showHtml = false, $showFrom = true) {
|
||||
function debug($var = false, $showHtml = null, $showFrom = true) {
|
||||
if (Configure::read('debug') > 0) {
|
||||
$file = '';
|
||||
$line = '';
|
||||
|
@ -116,10 +116,14 @@ TEXT;
|
|||
$template = $html;
|
||||
if (php_sapi_name() == 'cli') {
|
||||
$template = $text;
|
||||
} else {
|
||||
if ($showHtml === null) {
|
||||
$showHtml = true;
|
||||
}
|
||||
}
|
||||
$var = print_r($var, true);
|
||||
if ($showHtml) {
|
||||
$var = str_replace('<', '<', str_replace('>', '>', $var));
|
||||
$var = str_replace(array('<', '>'), array('<', '>'), $var);
|
||||
}
|
||||
printf($template, $file, $line, $var);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue