PHP Classes

preg_replace_callback T_FUNCTION error

Recommend this page to a friend!

      Pareto Security  >  All threads  >  preg_replace_callback T_FUNCTION error  >  (Un) Subscribe thread alerts  
Subject:preg_replace_callback T_FUNCTION error
Summary:Versions of PHP lower than 5.3 will display a T_FUNCTION error.
Messages:1
Author:Te Taipo
Date:2013-09-11 04:51:24
 

  1. preg_replace_callback T_FUNCTION error   Reply   Report abuse  
Picture of Te Taipo Te Taipo - 2013-09-11 04:51:24
Since PHP 5.2 and earlier does not support closures, the hexoctaldecode function will throw a T_FUNCTION error because of the preg_replace_callback, if your version of PHP is below 5.3.

Solution 1;

Find:

function hexoctaldecode( $code ) {
$code = ( substr_count( $code, '\\x' ) > 5 ) ?
urldecode( str_replace( '\\x', '%', $code ) ) : $code;
return preg_replace_callback(
"@\\\(x)?([0-9a-f]{2,3})@",
function( $x ){
return chr( $x[1] ? hexdec( $x[2] ):octdec( $x[2] ) );
},
$code
);
}

and replace with:

function hexoctaldecode( $code ) {
$code = ( substr_count( $code, '\\x' ) > 5 ) ? urldecode( str_replace( '\\x', '%', $code ) ) : $code;
$code = ( substr_count( $code, '\\x' ) > 5 ) ? urldecode( str_replace( '\\x', '%', $code ) ) : $code;
return urldecode( $code );
}

Solution 2: Upgrade to the latest stable release of PHP