4번독수리의 둥지
All PHP functions have the global scope 본문
http://php.net/manual/en/functions.user-defined.php
http://stackoverflow.com/a/14753616
The following codes use this feature for setting hex2bin() compartible in a class MyClass on PHP5.
class MyClass
{
public function __construct()
{
self::compat();
}
private static function compat()
{
if (!function_exists('hex2bin')) {
function hex2bin($hexString)
{
return pack('H*', $hexString);
}
}
}
public function foo($string)
{
return 'Hello '.hex2bin($string);
}
}
$MyObj = new MyClass();
echo $MyObj->foo('776f726c64');
'PHP' 카테고리의 다른 글
generating pagination in PHP (0) | 2016.02.22 |
---|---|
PHP define (0) | 2015.12.08 |
PHP memory management (0) | 2015.11.30 |
Downgrading a PECL Module (0) | 2015.11.02 |
check max get parameter length with PHP+cURL (0) | 2015.10.20 |