' . print_r($value, true) . ''; } if ($value === true) { return '(bool)TRUE'; } if ($value === false) { return '(bool)FALSE'; } if (is_numeric($value) && is_float($value)) { return '(float)' . $value; } if (is_numeric($value) && is_int($value)) { return '(int)' . $value; } if (is_string($value)) { return '(string)' . $value; } if (is_object($value)) { return '(object)' . get_class($value) . '
' . print_r($value, true) . ''; } return '(unknown)' . $value; } } if (!function_exists('ent')) { /** * Returns htmlentities - string * * ENT_COMPAT = Will convert double-quotes and leave single-quotes alone. * ENT_QUOTES = Will convert both double and single quotes. !!! * ENT_NOQUOTES = Will leave both double and single quotes unconverted. * * @param string $text * @return string Converted text */ function ent(string $text): string { return htmlentities($text, ENT_QUOTES, 'UTF-8'); } } if (!function_exists('hDec')) { /** * Convenience method for htmlspecialchars_decode * * @param string $text Text to wrap through htmlspecialchars_decode * @param int $quoteStyle * @return string Converted text */ function hDec(string $text, int $quoteStyle = ENT_QUOTES): string { if (is_array($text)) { return array_map('hDec', $text); } return trim(htmlspecialchars_decode($text, $quoteStyle)); } } if (!function_exists('entDec')) { /** * Convenience method for html_entity_decode * * @param string $text Text to wrap through htmlspecialchars_decode * @param int $quoteStyle * @return string Converted text */ function entDec(string $text, int $quoteStyle = ENT_QUOTES): string { if (is_array($text)) { return array_map('entDec', $text); } return !empty($text) ? trim(html_entity_decode($text, $quoteStyle, 'UTF-8')) : ''; } } if (!function_exists('extractFileInfo')) { /** * Focus is on the filename (without path) * * @deprecated Use native method instead * * @param string $filename to check on * @param string|null $type (extension/ext, filename/file, basename/base, dirname/dir) * @return mixed */ function extractFileInfo(string $filename, ?string $type = null) { $info = extractPathInfo($filename, $type); if ($info) { return $info; } $pos = strrpos($filename, '.'); $res = ''; switch ($type) { case 'extension': case 'ext': $res = ($pos !== false) ? substr($filename, $pos + 1) : ''; break; case 'filename': case 'file': $res = ($pos !== false) ? substr($filename, 0, $pos) : ''; break; default: break; } return $res; } } if (!function_exists('extractPathInfo')) { /** * Uses native PHP function to retrieve infos about a filename etc. * Improves it by not returning non-file-name characters from url files if specified. * So "filename.ext?foo=bar#hash" would simply be "filename.ext" then. * * @deprecated Use native method instead * * @param string $filename to check on * @param string|null $type (extension/ext, filename/file, basename/base, dirname/dir) * @param bool $fromUrl * @return mixed */ function extractPathInfo(string $filename, ?string $type = null, bool $fromUrl = false) { switch ($type) { case 'extension': case 'ext': $infoType = PATHINFO_EXTENSION; break; case 'filename': case 'file': $infoType = PATHINFO_FILENAME; break; case 'basename': case 'base': $infoType = PATHINFO_BASENAME; break; case 'dirname': case 'dir': $infoType = PATHINFO_DIRNAME; break; default: $infoType = $type; } $result = pathinfo($filename, $infoType); if ($fromUrl) { $pos = strpos($result, '#'); if ($pos !== false) { $result = substr($result, 0, $pos); } $pos = strpos($result, '?'); if ($pos !== false) { $result = substr($result, 0, $pos); } } return $result; } } if (!function_exists('pre')) { /** * Shows pr() messages, even with debug = 0. * Also allows additional customization. * * @param mixed $var * @param bool $collapsedAndExpandable * @param array