Tuesday 15 April 2014

php - Deprecated: preg_replace(): The /e modifier is deprecated error -



php - Deprecated: preg_replace(): The /e modifier is deprecated error -

hi i'm working on wordpress theme , write custom widget it's working properly. when create wp_debug = true it's giving error

deprecated: preg_replace(): /e modifier deprecated, utilize preg_replace_callback instead in ....

here preg_replace code

$status = preg_replace("/((http:\/\/|https:\/\/)[^ )]+)/e", "'<a href=\"$1\" title=\"$1\" $target >'. ((strlen('$1')>=$linkmaxlen ? substr('$1',0,$linkmaxlen).'...':'$1')).'</a>'", $status);

i'm trying alter this

$status = preg_replace_callback( "/((http:\/\/|https:\/\/)[^ )]+)/e", function($matches) { homecoming "'<a href=\"$1\" title=\"$1\" $target >'. ((strlen('$1')>=$linkmaxlen ? substr('$1',0,$linkmaxlen).'...':'$1')).'</a>'"; }, $status );

but it's not working. how can prepare this?

in callback, substitute $1 $matches[1]:

function($matches) { homecoming "'<a href=\"$matches[1]\" title=\"$matches[1]\" $target >' . ( ( strlen($matches[1]) >= $linkmaxlen ? ? substr(matches[1], 0, $linkmaxlen).'...' : matches[1] ) ) .'</a>'" },

php preg-replace preg-replace-callback

No comments:

Post a Comment