3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Make sure SimplePie is included. You may need to change this to match the location of autoloader.php // For 1.0-1.2: #require_once('../simplepie.inc'); // For 1.3+: require_once __DIR__ . DIRECTORY_SEPARATOR . 'autoloader.php'; // We'll process this feed with all of the default options. $feed = new SimplePie(); // Set which feed to process. // Single feed $feed = new SimplePie(); $feed->set_feed_url(array('http://www.corex-fitness.com/blog/feed/')); $feed->enable_order_by_date(false); //$feed->set_cache_location(basename(__DIR__) . '/cache'); $feed->init(); // Run SimplePie. $feed->init(); // This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it). $feed->handle_content_type(); // Let's begin our XHTML webpage code. The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag. //Shorten the description. function shorten($string, $length) { // By default, an ellipsis will be appended to the end of the text. $suffix = '&hellip;'; // Convert 'smart' punctuation to 'dumb' punctuation, strip the HTML tags, // and convert all tabs and line-break characters to single spaces. $short_desc = trim(str_replace(array("\r","\n", "\t"), ' ', strip_tags($string))); // Cut the string to the requested length, and strip any extraneous spaces // from the beginning and end. $desc = trim(substr($short_desc, 0, $length)); // Find out what the last displayed character is in the shortened string $lastchar = substr($desc, -1, 1); // If the last character is a period, an exclamation point, or a question // mark, clear out the appended text. if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?') $suffix=''; // Append the text. $desc .= $suffix; // Send the new description back to the page. return $desc; } function get_first_image_url($html) { if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) { return $matches[1]; } //else return 'url_of_default_image_if_post_has_no_img_tags.jpg'; } ?> <?php /* Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop. */ foreach ($feed->get_items(0, 1) as $item): ?> <div class=" col-1"> <div class="block block-list"> <div class="block-title"><strong> <span>Blog</span> </strong></div> <div class="block-content"><?php echo '<img src="' .get_first_image_url($item->get_content()). '"/>'; ?> <div class="content-title"><a href="<?php echo $item->get_permalink(); ?>" target="_blank"><?php echo $item->get_title(); ?></a></div> <p><?php echo shorten($item->get_description(), 150); ?></p> <p>Written on <?php echo $item->get_date('jS F Y'); ?></p> <p><a href="<?php echo $item->get_permalink(); ?>" target="_blank">Read More</a></p> </div> </div> </div> <?php endforeach; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: require_once(/in/autoloader.php): Failed to open stream: No such file or directory in /in/8LCTK on line 8 Fatal error: Uncaught Error: Failed opening required '/in/autoloader.php' (include_path='.:') in /in/8LCTK:8 Stack trace: #0 {main} thrown in /in/8LCTK on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.21, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: require_once(/in/autoloader.php): failed to open stream: No such file or directory in /in/8LCTK on line 8 Fatal error: require_once(): Failed opening required '/in/autoloader.php' (include_path='.:') in /in/8LCTK on line 8
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /in/8LCTK on line 8 Warning: require_once(__DIR__/autoloader.php): failed to open stream: No such file or directory in /in/8LCTK on line 8 Fatal error: require_once(): Failed opening required '__DIR__/autoloader.php' (include_path='.:') in /in/8LCTK on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5
Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /in/8LCTK on line 8 Warning: main(__DIR__/autoloader.php): failed to open stream: No such file or directory in /in/8LCTK on line 8 Fatal error: main(): Failed opening required '__DIR__/autoloader.php' (include_path='.:') in /in/8LCTK on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in /in/8LCTK on line 8 Warning: main(__DIR__/autoloader.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/8LCTK on line 8 Fatal error: main() [http://www.php.net/function.main]: Failed opening required '__DIR__/autoloader.php' (include_path='.:') in /in/8LCTK on line 8

preferences:
208.95 ms | 402 KiB | 355 Q