3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace TravelBlog\Element; use Contao\FrontendTemplate; use Contao\PageModel; class ContentArticlePreview extends \ContentElement { protected $strTemplate = "mod_articlepreview"; protected $idLevels = array(); protected function getFileFromSingleSRC($singleSRC) { if ($singleSRC == '') { return ''; } if (!\Validator::isUuid($singleSRC)) { return '<p class="error">'.$GLOBALS['TL_LANG']['ERR']['version2format'].'</p>'; } $objFile = \FilesModel::findByUuid($singleSRC); if ($objFile === null || !is_file(TL_ROOT . '/' . $objFile->path)) { return ''; } return $objFile->path; } /** * Generate content element */ protected function compile() { global $objPage; $query = ''; $pages = array(); $selectedPages = deserialize($this->article_list_pages); if (is_array($selectedPages)) { $articleListPages = $selectedPages; } elseif (!empty($selectedPages)) { $articleListPages = array($selectedPages); } else { $articleListPages = array(); } if (TL_MODE == 'FE') { $pageId = $objPage->id; } else { $objArticle = $this->Database->prepare("SELECT `pid` FROM `tl_article` WHERE `id`=?") ->execute($this->pid); if ($objArticle->next()) { $pageId = $objArticle->pid; } } if ($this->article_list_childrens) { array_splice($articleListPages, 0, 0, $this->getChildPages($pageId, false)); } if ($this->article_list_recursive) { for ($i=count($articleListPages)-1; $i>=0; $i--) { array_splice($articleListPages, $i+1, 0, $this->getChildPages($articleListPages[$i], true, $this->idLevels[$articleListPages[$i]]+1)); } } if (count($articleListPages)) { $objPages = $this->Database->prepare(" SELECT `id`, `alias`, `title`, `pageTitle`, `type`, `hide`, `protected`, `groups`, `titelimage`, `sorting` FROM tl_page WHERE " . (!$this->Input->cookie('FE_PREVIEW') ? "`published`='1' AND " : "") . " `id` IN (" . implode(',', $articleListPages) . ") ORDER BY `sorting` ") ->execute(); if ($objPages->numRows > 0) { $arrInactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']); $sql = " SELECT * FROM tl_article WHERE " . (!$this->Input->cookie('FE_PREVIEW') ? "`published`='1' AND " : "") . " `pid`=? ORDER BY `destinationdate`"; $this->import('FrontendUser', 'User'); while ($objPages->next()) { if ($this->article_list_hidden || ($objPages->hide != '1') || in_array($objPages->id, $selectedPages)) { $protectedPage = false; // Protected element if (!BE_USER_LOGGED_IN && $objPages->protected) { if (!FE_USER_LOGGED_IN) { $protectedPage = true; } else { $groups = deserialize($objPages->groups); if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) { $protectedPage = true; } } } $objArticles = $this->Database->prepare($sql)->execute($objPages->id); if ($objArticles->numRows > 0) { $articles = array(); while ($objArticles->next()) { if ($this->article_list_page_link && ($objArticles->numRows == 1)) { $link = ''; } else { $link = '/articles/'; if ($objArticles->inColumn != 'main') { $link .= $objArticles->inColumn . ':'; } $link .= (strlen($objArticles->alias) && !$GLOBALS['TL_CONFIG']['disableAlias']) ? $objArticles->alias : $objArticles->id; } $arrTeaserCssID = deserialize($objArticles->teaserCssID); $isProtected = $protectedPage; // Protected element if (!$protectedPage && !BE_USER_LOGGED_IN && $objArticles->protected) { if (!FE_USER_LOGGED_IN) { $isProtected = true; } else { $groups = deserialize($objArticles->groups); if (!is_array($groups) || empty($groups) || !count(array_intersect($groups, $this->User->groups))) { $isProtected = true; } } } $objFile = $this->getFileFromSingleSRC($objArticles->image); $articles[] = array ( 'id' => $objArticles->id, 'alias' => $objArticles->alias, 'active' => ($this->pid == $objArticles->id), 'class' => ($this->pid == $objArticles->id ? 'active'.($isProtected ? ' protected' : '') : ($isProtected ? 'protected' : '')), 'title' => $objArticles->title, 'teaser' => ($this->article_list_teaser ? $objArticles->teaser : ''), 'teaser_cssID' => $arrTeaserCssID[0], 'teaser_class' => $arrTeaserCssID[1], 'link' => $this->generateFrontendUrl($objPages->row(), $link), 'subheadline' => $objArticles->subheadline, 'destinationdate' => $objArticles->destinationdate, 'column' => $objArticles->inColumn, 'showPost' => $objArticles->showPost, 'image' => $objFile, 'protected' => $isProtected ); } $objFile = $this->getFileFromSingleSRC($objPages->titelimage); $pages[] = array ( 'name' => $objPages->title, 'title' => ($objPages->pageTitle != '' ? $objPages->pageTitle : $objPages->title), 'link' => $this->generateFrontendUrl($objPages->row()), 'protected' => $protectedPage, 'articles' => $articles, 'level' => (isset($this->idLevels[$objPages->id]) ? $this->idLevels[$objPages->id] : 0), 'active' => ($pageId == $objPages->id), 'class' => ($pageId == $objPages->id ? 'active'.($protectedPage ? ' protected' : '') : ($protectedPage ? 'protected' : '')), 'titelimage' => $objFile, 'sort' => (array_search($objPages->id, $articleListPages) !== FALSE ? array_search($objPages->id, $articleListPages) + 9000000 : $objPages->sorting) ); } } } } } elseif (TL_MODE == 'FE') { $this->log(sprintf('No articles for ID %d (%s) found.', $objPage->id, $objPage->title), 'ArticleList', TL_NOTICE); } if ((count($pages) > 0) && (count($articleListPages) > 0)) { usort($pages, array($this, 'pageSort')); } $this->Template->pages = $pages; if ($this->article_list_page_headline) { $hlNext = array('h1'=>'h2','h2'=>'h3','h3'=>'h4','h4'=>'h5','h5'=>'h6','h6'=>'p'); $this->Template->hlPage = (isset($hlNext[$this->hl]) ? $hlNext[$this->hl] : 'p'); } else { $this->Template->hlPage = false; } } /** * Helper function for usort */ protected function pageSort($a, $b) { if ($a['sort'] == $b['sort']) { return 0; } return ($a['sort'] < $b['sort']) ? -1 : 1; } /** * Gets all child pages if article_list_recursive is set */ protected function getChildPages($pageId, $recursive = true, $level=0) { $pageArray = array(); $objPages = $this->Database->prepare(" SELECT `id` FROM `tl_page` WHERE `pid`=? AND `type`='regular' ".(!$this->Input->cookie('FE_PREVIEW') ? " AND `published`='1' " : "")." ORDER BY `sorting` ")->execute($pageId); while ($objPages->next()) { $pageArray[] = $objPages->id; $this->idLevels[$objPages->id] = $level; if ($recursive) { $pageArray = array_merge($pageArray, $this->getChildPages($objPages->id, $recursive, $level+1)); } } return $pageArray; } }

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)
8.3.70.0130.00917.13
8.3.60.0090.00616.75
8.3.50.0110.00622.75
8.3.40.0070.00718.83
8.3.30.0030.01219.35
8.3.20.0000.00820.53
8.3.10.0000.00823.64
8.3.00.0040.00419.35
8.2.180.0090.00916.75
8.2.170.0090.00622.96
8.2.160.0080.00620.51
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0090.00626.16
8.2.120.0080.00020.96
8.2.110.0030.00620.94
8.2.100.0130.00018.03
8.2.90.0050.00318.14
8.2.80.0030.00617.97
8.2.70.0030.00617.88
8.2.60.0090.00017.93
8.2.50.0050.00318.07
8.2.40.0040.00418.34
8.2.30.0040.00418.27
8.2.20.0030.00517.93
8.2.10.0000.00918.29
8.2.00.0040.00417.91
8.1.280.0070.01125.92
8.1.270.0000.00823.96
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0030.00622.56
8.1.230.0040.00721.10
8.1.220.0000.00917.78
8.1.210.0060.00318.98
8.1.200.0030.00617.48
8.1.190.0000.00817.38
8.1.180.0030.00618.10
8.1.170.0030.00718.77
8.1.160.0080.00022.18
8.1.150.0030.00618.98
8.1.140.0100.00017.61
8.1.130.0000.00717.93
8.1.120.0000.00717.59
8.1.110.0040.00417.58
8.1.100.0040.00417.57
8.1.90.0030.00917.55
8.1.80.0040.00417.45
8.1.70.0030.00317.48
8.1.60.0000.00917.68
8.1.50.0080.00017.63
8.1.40.0040.00417.65
8.1.30.0080.00017.65
8.1.20.0060.00317.65
8.1.10.0090.00017.70
8.1.00.0050.00817.46
8.0.300.0070.00019.98
8.0.290.0070.00017.00
8.0.280.0040.00418.67
8.0.270.0040.00417.42
8.0.260.0050.00317.49
8.0.250.0000.00717.25
8.0.240.0030.00317.15
8.0.230.0050.00217.14
8.0.220.0000.01017.08
8.0.210.0030.00517.13
8.0.200.0040.00417.18
8.0.190.0040.00417.21
8.0.180.0000.00717.14
8.0.170.0030.00617.21
8.0.160.0050.00317.11
8.0.150.0030.00616.96
8.0.140.0000.00817.07
8.0.130.0040.00413.51
8.0.120.0090.00017.09
8.0.110.0050.00317.05
8.0.100.0040.00417.23
8.0.90.0040.00416.98
8.0.80.0100.00717.11
8.0.70.0040.00417.11
8.0.60.0050.00217.13
8.0.50.0040.00417.13
8.0.30.0130.00617.20
8.0.20.0060.01317.48
8.0.10.0030.00617.22
8.0.00.0110.00916.91
7.4.330.0060.00015.00
7.4.320.0000.00716.70
7.4.300.0000.00816.75
7.4.290.0000.00816.62
7.4.280.0000.00816.73
7.4.270.0040.00416.52
7.4.260.0040.00416.68
7.4.250.0040.00416.43
7.4.240.0050.00216.63
7.4.230.0040.00416.68
7.4.220.0130.00616.64
7.4.210.0030.01616.51
7.4.200.0000.00816.78
7.4.160.0070.00716.50
7.4.150.0160.00317.40
7.4.140.0110.01017.86
7.4.130.0080.01016.74
7.4.120.0110.00616.75
7.4.110.0110.00716.95
7.4.100.0190.00016.74
7.4.90.0210.00316.69
7.4.80.0100.01019.39
7.4.70.0080.00816.62
7.4.60.0120.00616.73
7.4.50.0000.00416.73
7.4.40.0120.00616.67
7.4.30.0170.00016.57
7.4.10.0030.01415.30
7.4.00.0070.00915.00
7.3.330.0000.00713.29
7.3.320.0000.00513.45
7.3.310.0070.00016.55
7.3.300.0030.00316.47
7.3.290.0130.00916.48
7.3.280.0050.01116.51
7.3.270.0100.01017.40
7.3.260.0200.00016.51
7.3.250.0090.01116.61
7.3.240.0150.00616.58
7.3.230.0070.01016.75
7.3.210.0100.00716.63
7.3.200.0090.00919.39
7.3.190.0160.00416.66
7.3.180.0080.00816.40
7.3.170.0000.01716.47
7.3.160.0120.00816.44
7.3.130.0120.00615.09
7.3.120.0110.00515.10
7.3.110.0080.00715.11
7.3.100.0100.00614.96
7.3.90.0050.00814.98
7.3.80.0080.00514.76
7.3.70.0060.00815.02
7.3.60.0070.00714.89
7.3.50.0080.00614.83
7.3.40.0050.00814.80
7.3.30.0050.00714.79
7.3.20.0060.00916.43
7.3.10.0100.00716.60
7.3.00.0080.00616.57
7.2.330.0120.01216.59
7.2.320.0060.01216.71
7.2.310.0060.01216.60
7.2.300.0180.00616.79
7.2.290.0120.00616.61
7.2.260.0090.00914.80
7.2.250.0110.00815.04
7.2.240.0070.01214.98
7.2.230.0060.00714.90
7.2.220.0050.01214.83
7.2.210.0060.00915.07
7.2.200.0050.00614.89
7.2.190.0070.00815.11
7.2.180.0070.00814.97
7.2.170.0100.00515.04
7.2.160.0030.01014.95
7.2.150.0060.00816.76
7.2.140.0050.01216.67
7.2.130.0070.00816.71
7.2.120.0030.01116.63
7.2.110.0050.01016.75
7.2.100.0040.01116.56
7.2.90.0030.01016.75
7.2.80.0020.01216.78
7.2.70.0100.00516.71
7.2.60.0070.00816.59
7.2.50.0060.00616.81
7.2.40.0070.00716.76
7.2.30.0070.00716.70
7.2.20.0040.00916.75
7.2.10.0040.00916.67
7.2.00.0030.01017.28
7.1.330.0070.00815.54
7.1.320.0070.00715.52
7.1.310.0040.00915.68
7.1.300.0030.01015.54
7.1.290.0030.01015.63
7.1.280.0050.00815.47
7.1.270.0050.00815.57
7.1.260.0060.01015.49
7.1.250.0050.00915.62
7.1.240.0080.00715.41
7.1.230.0060.01215.53
7.1.220.0040.01115.65
7.1.210.0060.00615.49
7.1.200.0040.00915.44
7.1.190.0060.00615.53
7.1.180.0050.00715.52
7.1.170.0050.00615.58
7.1.160.0040.01115.47
7.1.150.0060.00715.56
7.1.140.0030.00715.56
7.1.130.0070.00615.58
7.1.120.0060.00815.52
7.1.110.0040.00715.58
7.1.100.0070.00515.99
7.1.90.0040.01015.70
7.1.80.0040.01215.56
7.1.70.0090.00615.99
7.1.60.0040.00616.63
7.1.50.0040.01115.89
7.1.40.0040.00815.58
7.1.30.0060.00815.53
7.1.20.0040.01015.67
7.1.10.0070.00615.45
7.1.00.0060.02717.21
7.0.330.0000.01215.19
7.0.320.0060.01015.27
7.0.310.0060.00615.20
7.0.300.0060.00615.23
7.0.290.0030.00915.24
7.0.280.0070.00515.16
7.0.270.0050.00715.33
7.0.260.0050.01015.11
7.0.250.0040.00915.15
7.0.240.0070.00515.24
7.0.230.0070.00515.20
7.0.220.0040.01015.38
7.0.210.0060.00715.39
7.0.200.0050.00715.48
7.0.190.0070.00515.35
7.0.180.0040.00815.25
7.0.170.0070.00415.32
7.0.160.0050.00715.17
7.0.150.0060.00815.16
7.0.140.0050.02316.82
7.0.130.0030.01115.25
7.0.120.0080.00615.35
7.0.110.0040.00815.21
7.0.100.0120.01716.48
7.0.90.0090.01816.42
7.0.80.0070.01716.48
7.0.70.0110.02216.34
7.0.60.0140.01616.52
7.0.50.0150.01716.65
7.0.40.0060.01615.08
7.0.30.0040.01715.03
7.0.20.0050.01514.98
7.0.10.0090.02314.99
7.0.00.0050.01415.07
5.6.400.0050.01114.16
5.6.390.0080.00714.33
5.6.380.0040.01014.28
5.6.370.0040.01114.32
5.6.360.0050.01014.14
5.6.350.0060.00914.28
5.6.340.0060.00414.25
5.6.330.0050.00814.41
5.6.320.0060.00614.18
5.6.310.0050.00914.07
5.6.300.0060.00814.36
5.6.290.0030.01014.28
5.6.280.0050.02415.96
5.6.270.0070.00714.21
5.6.260.0060.00714.34
5.6.250.0040.01715.77
5.6.240.0060.01415.87
5.6.230.0070.01615.88
5.6.220.0060.02715.85
5.6.210.0080.01415.76
5.6.200.0070.02115.90
5.6.190.0050.01815.95
5.6.180.0100.02315.94
5.6.170.0060.01715.92
5.6.160.0070.01615.91
5.6.150.0090.02115.96
5.6.140.0080.01715.96
5.6.130.0080.01815.91
5.6.120.0080.01415.99
5.6.110.0050.02515.77
5.6.100.0110.02715.96
5.6.90.0040.01915.85
5.6.80.0060.01715.78
5.6.70.0040.02615.75
5.6.60.0080.01515.79
5.6.50.0060.01615.68
5.6.40.0030.01715.73
5.6.30.0030.01815.63
5.6.20.0090.01415.67
5.6.10.0090.01915.66
5.6.00.0040.01915.68
5.5.380.0030.01414.88
5.5.370.0060.01714.97
5.5.360.0060.01714.99
5.5.350.0050.01414.94
5.5.340.0070.02014.89
5.5.330.0060.02215.02
5.5.320.0060.01515.03
5.5.310.0070.01515.03
5.5.300.0070.01915.02
5.5.290.0080.02315.13
5.5.280.0040.02314.94
5.5.270.0080.01515.04
5.5.260.0060.01415.03
5.5.250.0060.01714.76
5.5.240.0060.01514.84
5.5.230.0040.01614.83
5.5.220.0050.01614.73
5.5.210.0030.01614.90
5.5.200.0020.03314.84
5.5.190.0030.01614.84
5.5.180.0050.01314.69
5.5.170.0080.00613.02
5.5.160.0020.01914.75
5.5.150.0070.01614.78
5.5.140.0060.01614.81
5.5.130.0050.01514.79
5.5.120.0030.01814.83
5.5.110.0070.01414.79
5.5.100.0050.01614.71
5.5.90.0050.01514.76
5.5.80.0040.01714.77
5.5.70.0070.01314.72
5.5.60.0050.01714.69
5.5.50.0030.01814.75
5.5.40.0030.01514.78
5.5.30.0050.01614.78
5.5.20.0070.01814.82
5.5.10.0040.01614.77
5.5.00.0040.01614.61
5.4.450.0060.01813.07
5.4.440.0040.01313.09
5.4.430.0060.01413.12
5.4.420.0070.01213.05
5.4.410.0030.01613.14
5.4.400.0060.01412.96
5.4.390.0040.01312.97
5.4.380.0050.01512.98
5.4.370.0070.01313.02
5.4.360.0040.01512.93
5.4.350.0090.01113.01
5.4.340.0060.01112.99
5.4.330.0080.00211.00
5.4.320.0050.01712.91
5.4.310.0030.01813.05
5.4.300.0010.01712.94
5.4.290.0040.01412.93
5.4.280.0060.01613.00
5.4.270.0070.01712.93
5.4.260.0030.01713.00
5.4.250.0030.01313.08
5.4.240.0030.01612.98
5.4.230.0040.01512.98
5.4.220.0070.01712.95
5.4.210.0050.01413.01
5.4.200.0050.01312.95
5.4.190.0060.01412.90
5.4.180.0050.01712.98
5.4.170.0040.01412.92
5.4.160.0010.01413.01
5.4.150.0050.01112.95
5.4.140.0040.01512.29
5.4.130.0030.01712.32
5.4.120.0080.00912.28
5.4.110.0070.01012.34
5.4.100.0010.01412.32
5.4.90.0080.00912.35
5.4.80.0050.01412.41
5.4.70.0050.01412.38
5.4.60.0050.01412.34
5.4.50.0050.01312.28
5.4.40.0050.01312.32
5.4.30.0040.01512.33
5.4.20.0050.01112.30
5.4.10.0040.01912.33
5.4.00.0030.01312.07

preferences:
45.37 ms | 401 KiB | 5 Q