3v4l.org

run code in 300+ PHP versions simultaneously
<?php function shortcode_promptedimage( $atts, $content=null ) { //extract() will make $image a variable extract( shortcode_atts( array( 'image' => 'holding.png' ), $atts ) ); //if you took in a filename, locate it in the uploads folder //we use a function because th uploads folder might be month-year $mediaUrl = prompted_media_url_getter($image) $formattedImg='' if ($image==''){ //some default }else{ $formattedImg = "<img class=\"promptedimage\" src=\"".$mediaUrl."\""; } //build the HTML $prompted_htmlBucket .= PHP_EOL."<div class=\"promptedimage-shortcode-wrapper\">"; $prompted_htmlBucket .= PHP_EOL.$formattedImg; //handle the content if there is any if(!is_null($content)){ //optional wpautop( wptexturize( $content )); //optional but ensures nested shortcodes are run $prompted_htmlBucket .= PHP_EOL.do_shortcode($content); } //and wrap it up $prompted_htmlBucket .= PHP_EOL."</div><!-- end div class=\"promptedimage-shortcode-wrapper\"-->"; return $prompted_htmlBucket; } add_shortcode( 'promptedimage', 'shortcode_promptedimage' ); //useful filters //use shortcodes in excerpts //add_filter( 'get_the_excerpt', 'shortcode_unautop'); //add_filter( 'get_the_excerpt', 'do_shortcode'); //use shortcodes in text widget //add_filter( 'widget_text', 'shortcode_unautop'); //add_filter('widget_text', 'do_shortcode');

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.280.0900.05319.07
5.4.270.0070.03718.86
5.4.260.0000.04019.08
5.4.250.2030.03719.21
5.4.240.2270.04719.19
5.4.230.2100.03719.14
5.4.220.2030.04318.94
5.4.210.1830.03319.08
5.4.200.2000.05019.16
5.4.190.2030.05319.17
5.4.180.1930.03719.07
5.4.170.2000.04019.17
5.4.160.1770.04318.81
5.4.150.1930.04019.05
5.4.140.2270.04016.29
5.4.130.1970.03716.33
5.4.120.2100.04016.38
5.4.110.1900.04316.45
5.4.100.1930.03716.36
5.4.90.2170.05016.40
5.4.80.1970.03316.34
5.4.70.1930.04316.43
5.4.60.2170.03316.52
5.4.50.1870.04016.34
5.4.40.0070.05716.39
5.4.30.0030.03316.34
5.4.20.0200.07316.34
5.4.10.1730.04016.27
5.4.00.2100.04015.77
5.3.280.1830.04714.63
5.3.270.2000.04714.61
5.3.260.2070.03714.63
5.3.250.2000.04714.61
5.3.240.1970.04314.61
5.3.230.2000.04014.50
5.3.220.1830.05014.57
5.3.210.0030.03714.63
5.3.200.0070.06714.66
5.3.190.0630.04314.68
5.3.180.1830.03314.65
5.3.170.2070.04014.55
5.3.160.2030.04314.47
5.3.150.2300.03714.64
5.3.140.1700.04314.56
5.3.130.1800.04014.52
5.3.120.1700.04314.54
5.3.110.1830.04714.63
5.3.100.2200.04014.19
5.3.90.1530.03314.14
5.3.80.0070.08313.95
5.3.70.0100.06314.17
5.3.60.0800.03314.01
5.3.50.2230.03013.85
5.3.40.1930.03013.95
5.3.30.2130.03714.13
5.3.20.1700.03313.77
5.3.10.1700.04313.77
5.3.00.2030.04313.65

preferences:
141.72 ms | 1394 KiB | 7 Q