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=12691__cb=e3755e1c35__h=1378130258__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=fce9986117f37450268dc2b69a656030__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=1a3d39ada87663adc053e469f9ee1951' target=''>test normal text link</a><img src="http://localhost:9003/openx/www/delivery/myview.php?p=__pid=03f3ec0d386cab28__sid=5874__bid=12691__cb=7da209cd79__h=1378130258__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=fce9986117f37450268dc2b69a656030__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=989edb9bf0058afaf9b0e02f3bc546af" alt="" width="1" height="1" /> EOT; $ad = frengo_ad_common::addClickTracking($ad); echo $ad; ?>
Output for 5.2.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<a href="{clickurl}__maxdest=http%3A%2F%2Flocalhost%3A9003%2Fopenx%2Fwww%2Fdelivery%2Fmyck.php%3Fp%3D__pid%3D03f3ec0d386cab28__sid%3D5874__bid%3D12691__cb%3De3755e1c35__h%3D1378130258__channel_ids%3D%252C408%252C__uid%3D2A744361-BDDF-4266-B928-F6D3332CF10F__tp%3Dfce9986117f37450268dc2b69a656030__os%3DiPhone%2BOS__ip%3D50.17.80.240__ua%3DMozilla%252F5.0%2B%2528iPad%253B%2BU%253B%2BCPU%2BOS%2B3_2%2Blike%2BMac%2BOS%2BX%253B%2Ben-us%2529%2BAppleWebKit%252F531.21.10%2B%2528KHTML%252C%2Blike%2BGecko%2529%2BVersion%252F4.0.4%2BMobile%252F7B367%2BSafari%252F531.21.10__ho%3D50.17.80.240__s%3D1a3d39ada87663adc053e469f9ee1951" target=''>test normal text link</a><img src="http://localhost:9003/openx/www/delivery/myview.php?p=__pid=03f3ec0d386cab28__sid=5874__bid=12691__cb=7da209cd79__h=1378130258__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=fce9986117f37450268dc2b69a656030__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=989edb9bf0058afaf9b0e02f3bc546af" alt="" width="1" height="1" />
Output for 5.1.0 - 5.2.1
Warning: preg_replace_callback(): Unable to call custom replacement function in /in/5BBKH on line 9 <a href='http://localhost:9003/openx/www/delivery/myck.php?p=__pid=03f3ec0d386cab28__sid=5874__bid=12691__cb=e3755e1c35__h=1378130258__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=fce9986117f37450268dc2b69a656030__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=1a3d39ada87663adc053e469f9ee1951' target=''>test normal text link</a><img src="http://localhost:9003/openx/www/delivery/myview.php?p=__pid=03f3ec0d386cab28__sid=5874__bid=12691__cb=7da209cd79__h=1378130258__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=fce9986117f37450268dc2b69a656030__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=989edb9bf0058afaf9b0e02f3bc546af" alt="" width="1" height="1" />
Output for 5.0.0 - 5.0.5
Warning: preg_replace_callback(): requires argument 2, 'frengo_ad_common::formatClickURLMatch', to be a valid callback in /in/5BBKH on line 9 <a href='http://localhost:9003/openx/www/delivery/myck.php?p=__pid=03f3ec0d386cab28__sid=5874__bid=12691__cb=e3755e1c35__h=1378130258__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=fce9986117f37450268dc2b69a656030__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=1a3d39ada87663adc053e469f9ee1951' target=''>test normal text link</a><img src="http://localhost:9003/openx/www/delivery/myview.php?p=__pid=03f3ec0d386cab28__sid=5874__bid=12691__cb=7da209cd79__h=1378130258__channel_ids=%2C408%2C__uid=2A744361-BDDF-4266-B928-F6D3332CF10F__tp=fce9986117f37450268dc2b69a656030__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=989edb9bf0058afaf9b0e02f3bc546af" alt="" width="1" height="1" />
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5BBKH on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5BBKH on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/5BBKH on line 6
Process exited with code 255.