3v4l.org

run code in 300+ PHP versions simultaneously
<?php use Joomla\CMS\Language\Text; use Joomla\CMS\Date\Date; use Joomla\CMS\Factory; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*') ->from('#__content') ->order('id DESC') ->limit('3'); $db->setQuery($query); ?> $cardTemplate = <<<HTML <div class="col-lg-4 col-md-6"> <div class="card"> %1$s <div class="card-body"> <a href="%2$s"> <h5 class="card-title mb-4">%3$s</h5> </a> <time datetime="%4$s" class="mb-2 text-muted">%4$s</time> <p class="card-text">%5$s</p> </div> </div> </div> HTML; $cards = []; foreach ($db->loadObjectList() as $row) { $introImage = json_decode($r->images)->image_intro ?? null; $cardTop = !$introimage || $introimage == '/' ? '<div class="card-img-top holding-image" alt="' . $row->title . '"></div>' : '<img class="card-img-top" src="' . $introImage . '" alt="' . $row->title . '"/>', $cards[] = sprintf( $cardTemplate, $cardTop, // %1$s JRoute::_('index.php?option=com_content&view=article&id=' . $row->id), // %2$s $row->title, // %3$s $row->publish_up, // %4$s mb_strimwidth($row->introtext, 0, 80, "..."), // %5$s } } $pageTemplate = <<<HTML <h2>Heading Here</h2> <div class="row"> %s </div> HTML; printf( $pageTemplate, implode("\n", $cards) );
Output for git.master, git.master_jit, rfc.literals, rfc.partials
Fatal error: Uncaught Error: Class "JFactory" not found in /in/1po1G:7 Stack trace: #0 {main} thrown in /in/1po1G on line 7
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
38.81 ms | 458 KiB | 5 Q