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');
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected '$formattedImg' (T_VARIABLE) in /in/a8ts1 on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/a8ts1 on line 13
Process exited with code 255.

preferences:
183.24 ms | 1395 KiB | 65 Q