resolve some errors in php logic, like strlen with str containing space that is interpreted as array instead of string

This commit is contained in:
asus
2023-11-08 16:13:25 +01:00
parent 036473d58f
commit 3429d5dda3
41 changed files with 2653 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
<?php
// https://stackify.com/how-to-log-to-console-in-php/
function mp_log($output) {
$type = gettype($output);
if ($type == 'object')
$output = serialize($output);
$time = date('H:i');
$file = '/var/www/html/wp-debug.log';
file_put_contents($file, $time . " " . $output . "\n", FILE_APPEND);
}
function mp_console_log($output) {
$js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . ');';
$js_code = '<script>' . $js_code . '</script>';
echo $js_code;
}
// function mp_console_log($output, $with_script_tags = true) {
// $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) .
// ');';
// if ($with_script_tags) {
// $js_code = '<script>' . $js_code . '</script>';
// }
// echo $js_code;
// }
?>