3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function get_tumbail($imgSrc,$placeholder_image){ $imgPattern = "/(http\:\/\/ww\d+\.sinaimg\.cn\/)(\w+)(\/\S+\.(jpg|gif))/i"; $matches = null; $result = preg_match($imgPattern, $imgSrc, $matches); if (!$result) { return $placeholder_image; } return $matches[1] . 'thumbnail' . $matches[3]; } $placeholder_image = 'images/transparent.gif'; $imgStr = '<img src="http://ww2.sinaimg.cn/bmiddle/a3d444e3jw1ez79amvdi1j20l50s8gpl.jpg"/>'; $imgStr = preg_replace_callback('#<img([^>]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#',function($match) { var_dump($match); return sprintf('<img${1}src="%s" data-original="${2}" class="lazy"${3}><noscript><img${1}src="${2}"${3}></noscript>', get_tumbail($match[2],$placeholder_image)) },$imgStr); var_dump($imgStr);
based on X9HAE
Output for 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '}', expecting ';' in /in/dvfoK on line 16
Process exited with code 255.
Output for 5.3.21 - 5.6.16
Parse error: syntax error, unexpected '}' in /in/dvfoK on line 16
Process exited with code 255.