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) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1po1G
function name:  (null)
number of ops:  24
compiled vars:  !0 = $db, !1 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_STATIC_METHOD_CALL                                  'JFactory', 'getDbo'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
    8     3        INIT_METHOD_CALL                                         !0, 'getQuery'
          4        SEND_VAL_EX                                              <true>
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
    9     7        INIT_METHOD_CALL                                         !1, 'select'
          8        SEND_VAL_EX                                              '%2A'
          9        DO_FCALL                                      0  $6      
   10    10        INIT_METHOD_CALL                                         $6, 'from'
         11        SEND_VAL_EX                                              '%23__content'
         12        DO_FCALL                                      0  $7      
   11    13        INIT_METHOD_CALL                                         $7, 'order'
         14        SEND_VAL_EX                                              'id+DESC'
         15        DO_FCALL                                      0  $8      
   12    16        INIT_METHOD_CALL                                         $8, 'limit'
         17        SEND_VAL_EX                                              '3'
         18        DO_FCALL                                      0          
   13    19        INIT_METHOD_CALL                                         !0, 'setQuery'
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0          
   15    22        ECHO                                                     '%0A%24cardTemplate+%3D+%3C%3C%3CHTML%0A%3Cdiv+class%3D%22col-lg-4+col-md-6%22%3E%0A++++%3Cdiv+class%3D%22card%22%3E%0A++++++++%251%24s%0A++++++++%3Cdiv+class%3D%22card-body%22%3E%0A++++++++++++%3Ca+href%3D%22%252%24s%22%3E%0A++++++++++++++++%3Ch5+class%3D%22card-title+mb-4%22%3E%253%24s%3C%2Fh5%3E%0A++++++++++++%3C%2Fa%3E%0A++++++++++++%3Ctime+datetime%3D%22%254%24s%22+class%3D%22mb-2+text-muted%22%3E%254%24s%3C%2Ftime%3E%0A++++++++++++%3Cp+class%3D%22card-text%22%3E%255%24s%3C%2Fp%3E%0A++++++++%3C%2Fdiv%3E%0A++++%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0AHTML%3B%0A%0A%24cards+%3D+%5B%5D%3B%0Aforeach+%28%24db-%3EloadObjectList%28%29+as+%24row%29+%7B%0A++++%24introImage+%3D+json_decode%28%24r-%3Eimages%29-%3Eimage_intro+%3F%3F+null%3B%0A++++%24cardTop+%3D+%21%24introimage+%7C%7C+%24introimage+%3D%3D+%27%2F%27%0A++++++++++++%3F+%27%3Cdiv+class%3D%22card-img-top+holding-image%22+alt%3D%22%27+.+%24row-%3Etitle+.+%27%22%3E%3C%2Fdiv%3E%27%0A++++++++++++%3A+%27%3Cimg+class%3D%22card-img-top%22+src%3D%22%27+.+%24introImage+.+%27%22+alt%3D%22%27+.+%24row-%3Etitle+.+%27%22%2F%3E%27%2C%0A%0A++++%24cards%5B%5D+%3D+sprintf%28%0A++++++++%24cardTemplate%2C%0A++++++++%24cardTop%2C++%2F%2F+%251%24s%0A++++++++JRoute%3A%3A_%28%27index.php%3Foption%3Dcom_content%26view%3Darticle%26id%3D%27+.+%24row-%3Eid%29%2C++%2F%2F+%252%24s%0A++++++++%24row-%3Etitle%2C++%2F%2F+%253%24s%0A++++++++%24row-%3Epublish_up%2C++%2F%2F+%254%24s%0A++++++++mb_strimwidth%28%24row-%3Eintrotext%2C+0%2C+80%2C+%22...%22%29%2C++%2F%2F+%255%24s%0A++++%7D%0A%7D%0A%0A%24pageTemplate+%3D+%3C%3C%3CHTML%0A%3Ch2%3EHeading+Here%3C%2Fh2%3E%0A%3Cdiv+class%3D%22row%22%3E%0A++++%25s%0A%3C%2Fdiv%3E%0AHTML%3B%0A%0Aprintf%28%0A++++%24pageTemplate%2C%0A++++implode%28%22%5Cn%22%2C+%24cards%29%0A%29%3B'
   58    23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
89.59 ms | 466 KiB | 7 Q