3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class frengo_ad_common { public static function addClickTracking($ad) { $regexp = "<a(.+)href=[\"'](.*)[\"']"; $ad = preg_replace_callback("/$regexp/iU", "frengo_ad_common::formatClickURLMatch", $ad); return $ad; } public static function formatClickURLMatch($matches) { $matchedURL = html_entity_decode($matches[2]); $matchedURL = urlencode($matchedURL); $matchedURL = htmlentities($matchedURL); return '<a'.$matches[1].'href="{clickurl}'. "__maxdest=" . $matchedURL . '"'; } } $ad = <<<EOT <a href="http://localhost:9003/openx/www/delivery/myck.php?p=__pid=03f3ec0d386cab28__sid=5874__bid=12489__cb=2d1e14eca6__h=1378128272__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=e1c96c1dd763da124e8bf413af67778c__os=iPhone+OS__ip=50.17.80.240__ua=Mozilla%2F5.0+%28iPad%3B+U%3B+CPU+OS+3_2+like+Mac+OS+X%3B+en-us%29+AppleWebKit%2F531.21.10+%28KHTML%2C+like+Gecko%29+Version%2F4.0.4+Mobile%2F7B367+Safari%2F531.21.10__ho=50.17.80.240__s=0978e7e108fcfe78c0cf1fba91bd6740__maxdest=https://www.facebook.com/"> <img src="https://fbcdn-creative-a.akamaihd.net/hads-ak-prn1/s110x80/735361_6006542277281_1784864893_n.png" />Click Here </a> EOT; frengo_ad_common::addClickTracking($ad); ?>
Output for 5.2.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Output for 5.1.0 - 5.2.1
<br /> <b>Warning</b>: preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unable to call custom replacement function in <b>/in/lMNs4</b> on line <b>9</b><br />
Output for 5.0.0 - 5.0.5
<br /> <b>Warning</b>: preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: requires argument 2, 'frengo_ad_common::formatClickURLMatch', to be a valid callback in <b>/in/lMNs4</b> on line <b>9</b><br />
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/lMNs4</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/lMNs4</b> on line <b>6</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in <b>/in/lMNs4</b> on line <b>6</b><br />
Process exited with code 255.