3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* , , / \ ((__-^^-,-^^-__)) `-_---' `---_-' `--|o` 'o|--' \ ` / ): :( :o_o: "-" This file is part of CookieLayer. CookieLayer is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CookieLayer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>. */ /** * CakePHP CookieLayerHelper to use without cakephp framework. * @author Juan Fran */ if(!defined('ROOT')) die('ROOT constant not defined!'); if(!defined('DS')) die('DS constant not defined!'); class CookieLayerHelper { /* Default settings This script have some options more that cakephp CookieLayerHelper script. */ private $settings = array( // Text messages to show. If you want to change the messages values, you´ll need to change the Locales files from cakephp. // IMPORTANT TO CHANGE THE MESSAGE VALUES: // You can change the msg string (msgstr) param in the .po files inside the locale folder. // or You can change the following text array values and then change the msgid and msgstr in each .po file, and compile the .po file. 'texts' => array( 'normalText' => 'we use our own cookies and cookies from others to improve our services by analyzing their browsing habits. If you continue to browse, we consider that you accept the terms. You can change the settings or get more information ', 'strictText' => 'we use our own cookies and cookies from others to improve our services by analyzing their browsing habits. By accepting, you approve our cookies policy. You can change the settings or get more information ', 'underStdText' => 'Understood', 'agreeText' => 'Agree', 'disagreeTest' => 'Disagree', 'title' => 'Cookie Policy', 'here' => 'here' ), 'locale' => 'en_GB.UTF-8', // this may differ depending on the server. Default en_GB.UTF-8 'langDomain' => 'cakeCookieLayerHelper', // Domain for cakephp translations. Default cakeCookieLayerHelper. 'localeDir' => 'Locale', // Dir name only. Default /php_js/Locale 'mode' => 'strict', // normal: show understood button and include all cookies without ask. // strict: show agree and disagree buttons, and only include cookies when user press agre button. It takes normalText or strictText 'position' => 'bottom', // Layer position. Default is bottom. Options: [poisition => 'top' or 'bottom'] 'themePath' => '', // Css file. Relative path. Default /php_js/css/CookieLayer.css 'theme' => 'Dark', // Theme. Default theme Dark. 'separator' => ' - ', // Separator for links. Default '-'. 'showLayerOnce' => false, // Show the layer once and then it hides. Default false. 'autoHide' => true, // Auto hide. Indicates that the bar is going to hide in x (how is indicated in param timeOut) seconds. Default true. 'timeOut' => 10, // Time out for auto hide and showLayerOnce. 'scriptPath' => '', // Js file. Relative path. Default /php_js/js/CookieLayer.js 'scriptLoader' => '', // Js Loader file. Relative path. Default is /php_js/js/CookieLayerLoader.js // Function to execute when the user click the accept button or understood. // When the user enter twice to the site, this function is going to execute again, because the user accepted the terms the first time. 'onAceptClick' => ' /* Instead of load the source code via CookieLayerLoader.js, here you can include more source code. */ ', 'onDisagreeClick' => ' /* Here you can include code that is going to execute when disagree button was pressed */ ', ); public function __construct($settings = array()) { $this->settings = (array_merge($this->settings, (array) $settings)); // Default paths if(empty($this->settings['themePath'])) $this->settings['themePath'] = 'css' . DS . 'CookieLayer.css'; if(empty($this->settings['scriptPath'])) $this->settings['scriptPath'] = 'js' . DS . 'CookieLayer.js'; if(empty($this->settings['scriptLoader'])) $this->settings['scriptLoader'] = 'js' . DS . 'CookieLayerLoader.js'; // Check files if(!file_exists(ROOT . $this->settings['themePath'])){ throw new Exception('Error. Css theme file ' . ROOT . $this->settings['themePath'] . ' not found!'); } if(!file_exists(ROOT . $this->settings['scriptPath'])){ throw new Exception('Error. Js script file ' . ROOT . $this->settings['scriptPath'] . ' not found!'); } if(!file_exists(ROOT . $this->settings['scriptLoader'])){ throw new Exception('Error. Js Loader script file ' . ROOT . $this->settings['scriptLoader'] . ' not found!'); } if(!file_exists(ROOT . $this->settings['localeDir'])){ throw new Exception('Error. Locale dir ' . ROOT . $this->settings['localeDir'] . ' not found!'); } // If you made a call to a setLocale function before call constructor, this line can be commented setlocale(LC_ALL, $this->settings['locale']); bindtextdomain($this->settings['langDomain'], $this->settings['localeDir']); bind_textdomain_codeset($this->settings['langDomain'], 'UTF-8'); textdomain($this->settings['langDomain']); } private function getOptions() { if ($this->settings['mode'] == 'normal') // Get links return '<a href=\'#\' class=\'lAgree\'>' . _($this->settings['texts']['underStdText']) . '</a>'; else return '<a href=\'#\' class=\'lAgree\'>' . _($this->settings['texts']['agreeText']) . '</a>' . ' ' . '<a href=\'#\' class=\'lDisagree\'>' . _($this->settings['texts']['disagreeTest']) . '</a>'; } function url(){ if(isset($_SERVER['HTTPS'])){ $protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http"; } else{ $protocol = 'http'; } //return $protocol . "://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; return $protocol . "://localhost/dev.cookielayer.com/php_js/"; } public function render() { echo '<link rel=\'stylesheet\' href=\'' . $this->url() . $this->settings['themePath'] . '\' type=\'text/css\'>'; /* * * <div id="CookieLayer" style="bottom: -66px;" class="hideToBottom"> * <div id="cL_Dark"> * * <div id="CookieLayerHeader" class="border-top"> * * <span class="title"> * <a href="#">Política de Cookies</a></span></div> * * <div id="CookieLayerBody" class="border-top"><p>Utilizamos cookies propias y de terceros para mejorar nuestros servicios mediante el análisis de sus hábitos de navegación. Si continua navegando, consideramos que aceptas los terminos. Puede cambiar la configuración u obtener más información <a href="/pages/aviso">aquí</a>. - <a href="#" class="lAgree">Entendido</a></p></div> * * <div id="CookieLayerFooter" style="display: none;"><span class="title"><a href="#">Política de Cookies</a></span></div></div></div> * * * */ $text = ($this->settings['mode']=='normal') ? _($this->settings['texts']['normalText']): _($this->settings['texts']['strictText']); echo '<div id=\'CookieLayer\'> <div id=\'' . 'cL_' . $this->settings['theme'] . '\'> <div id=\'CookieLayerHeader\' class=\'border-top\'> <span class=\'title\'><a href=\'#\'>' . _($this->settings['texts']['title']) . '</a></span> </div> <div id=\'CookieLayerBody\' class=\'border-top\'> <p>' . $text . $this->getOptions() . '</p> </div> <div id=\'CookieLayerFooter\'> <span class=\'title\'><a href=\'#\'>' . _($this->settings['texts']['title']) . '</a></span> </div> </div> </div> '; echo '<script src=\'' . $this->url() . $this->settings['scriptPath'] . '\' type=\'text/javascript\'></script>'; ?> <script type="text/javascript"> var config = { theme : '<?php echo $this->settings['theme']; ?>', mode : '<?php echo $this->settings['mode']; ?>', position : '<?php echo $this->settings['position']; ?>', autoHide : <?php if($this->settings['position']) echo 'true'; else echo 'false'; ?>, showLayerOnce : <?php if($this->settings['showLayerOnce']) echo 'true'; else echo 'false'; ?>, timeOut : <?php echo $this->settings['timeOut']; ?>, scriptLoader : '<?php echo $this->url() . $this->settings['scriptLoader']; ?>', onAceptClick : function(){<?php echo $this->settings['onAceptClick']; ?>}, onDisagreeClick: function(){<?php echo $this->settings['onDisagreeClick']; ?>} }; // Initialize. window.CookieLayer.initialize(config); </script> <?php } }

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.60.0160.00016.75
8.3.50.0070.00719.94
8.3.40.0110.00418.92
8.3.30.0070.00719.04
8.3.20.0000.00720.41
8.3.10.0050.00323.61
8.3.00.0070.00317.59
8.2.180.0070.00716.50
8.2.170.0060.01222.96
8.2.160.0100.00320.24
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0050.00221.02
8.2.110.0000.01022.13
8.2.100.0120.00017.97
8.2.90.0040.00419.34
8.2.80.0040.00417.97
8.2.70.0000.01017.75
8.2.60.0000.00818.16
8.2.50.0030.00618.07
8.2.40.0030.00518.28
8.2.30.0040.00418.11
8.2.20.0030.00617.92
8.2.10.0040.00418.19
8.2.00.0000.00817.81
8.1.280.0040.01125.92
8.1.270.0080.00022.37
8.1.260.0000.00826.35
8.1.250.0060.00328.09
8.1.240.0100.00023.80
8.1.230.0060.00619.27
8.1.220.0080.00017.77
8.1.210.0080.00018.77
8.1.200.0030.00617.48
8.1.190.0000.00817.47
8.1.180.0040.00418.10
8.1.170.0040.00418.59
8.1.160.0000.00722.05
8.1.150.0040.00418.90
8.1.140.0030.00717.57
8.1.130.0030.00317.84
8.1.120.0050.00317.54
8.1.110.0000.00717.48
8.1.100.0040.00417.49
8.1.90.0050.00217.51
8.1.80.0040.00417.58
8.1.70.0000.00817.43
8.1.60.0060.00317.60
8.1.50.0000.00817.65
8.1.40.0040.00417.64
8.1.30.0060.00317.73
8.1.20.0000.00817.65
8.1.10.0000.00717.60
8.1.00.0050.00317.40
8.0.300.0080.00018.77
8.0.290.0050.00316.88
8.0.280.0070.00018.45
8.0.270.0000.00717.21
8.0.260.0030.00317.40
8.0.250.0070.00017.08
8.0.240.0000.00817.02
8.0.230.0030.00517.05
8.0.220.0030.00316.94
8.0.210.0040.00416.98
8.0.200.0030.00317.13
8.0.190.0050.00317.04
8.0.180.0000.00717.07
8.0.170.0040.00417.07
8.0.160.0040.00417.01
8.0.150.0070.00016.91
8.0.140.0000.00716.97
8.0.130.0030.00313.43
8.0.120.0050.00316.97
8.0.110.0000.00717.01
8.0.100.0000.00716.92
8.0.90.0040.00417.04
8.0.80.0120.00316.99
8.0.70.0000.00916.89
8.0.60.0050.00217.04
8.0.50.0040.00416.99
8.0.30.0120.01017.31
8.0.20.0120.01017.40
8.0.10.0000.00816.96
8.0.00.0050.01616.88
7.4.330.0000.00515.07
7.4.320.0070.00016.70
7.4.300.0000.00616.50
7.4.290.0030.00316.55
7.4.280.0040.00416.46
7.4.270.0030.00516.56
7.4.260.0040.00416.56
7.4.250.0040.00416.46
7.4.240.0070.00016.61
7.4.230.0040.00416.75
7.4.220.0120.01116.63
7.4.210.0080.00616.60
7.4.200.0050.00216.34
7.4.160.0150.00616.57
7.4.150.0120.00617.40
7.4.140.0120.01017.86
7.4.130.0090.00816.66
7.4.120.0070.01016.53
7.4.110.0100.00716.77
7.4.100.0090.01316.65
7.4.90.0120.00916.45
7.4.80.0120.01219.39
7.4.70.0080.01316.49
7.4.60.0100.00616.83
7.4.50.0080.00016.48
7.4.40.0100.00716.49
7.4.30.0120.00316.70
7.4.00.0060.00914.86
7.3.330.0030.00313.19
7.3.320.0000.00513.36
7.3.310.0050.00216.40
7.3.300.0070.00016.29
7.3.290.0070.01116.28
7.3.280.0100.00816.33
7.3.270.0060.01517.40
7.3.260.0070.01116.27
7.3.250.0120.00816.62
7.3.240.0130.00316.32
7.3.230.0070.01016.42
7.3.210.0110.00716.35
7.3.200.0090.00919.39
7.3.190.0070.01016.32
7.3.180.0080.00816.61
7.3.170.0160.00616.35
7.3.160.0060.01016.56
7.3.120.0080.01114.73
7.3.110.0100.00614.86
7.3.100.0100.01014.98
7.3.90.0090.00614.75
7.3.80.0100.00314.49
7.3.70.0080.00814.67
7.3.60.0060.00914.92
7.3.50.0110.00714.62
7.3.40.0060.00614.93
7.3.30.0030.01014.88
7.3.20.0000.01516.54
7.3.10.0040.00816.56
7.3.00.0000.01016.67
7.2.330.0130.01016.46
7.2.320.0180.00616.84
7.2.310.0100.01316.52
7.2.300.0060.01616.45
7.2.290.0150.00316.54
7.2.250.0090.00715.29
7.2.240.0070.01014.88
7.2.230.0000.01514.98
7.2.220.0060.00915.19
7.2.210.0070.00715.17
7.2.200.0030.01015.08
7.2.190.0040.01515.02
7.2.180.0090.00614.70
7.2.170.0000.01215.11
7.2.160.0030.01314.88
7.2.150.0100.00716.81
7.2.140.0040.00716.94
7.2.130.0030.00916.84
7.2.120.0040.01116.71
7.2.110.0040.01116.80
7.2.100.0060.00916.95
7.2.90.0030.01316.83
7.2.80.0110.00316.73
7.2.70.0000.01717.00
7.2.60.0000.01117.00
7.2.50.0040.01216.77
7.2.40.0070.01116.68
7.2.30.0030.00916.74
7.2.20.0070.00816.88
7.2.10.0120.00316.68
7.2.00.0090.00918.19
7.1.330.0090.00915.50
7.1.320.0030.00915.87
7.1.310.0060.00615.98
7.1.300.0040.00715.55
7.1.290.0030.00915.68
7.1.280.0060.00315.63
7.1.270.0040.00415.69
7.1.260.0000.00915.54
7.1.250.0000.01415.65
7.1.240.0090.00615.78
7.1.230.0060.00315.83
7.1.220.0060.00715.68
7.1.210.0060.00615.71
7.1.200.0120.00615.50
7.1.190.0050.00815.61
7.1.180.0070.00415.47
7.1.170.0140.00015.69
7.1.160.0100.00315.65
7.1.150.0060.00915.89
7.1.140.0060.00315.78
7.1.130.0040.00715.48
7.1.120.0070.00715.78
7.1.110.0030.00615.60
7.1.100.0060.00816.92
7.1.90.0100.00315.53
7.1.80.0040.01115.77
7.1.70.0070.00716.14
7.1.60.0050.01517.53
7.1.50.0050.01015.94
7.1.40.0090.00615.69
7.1.30.0030.00615.81
7.1.20.0030.01015.65
7.1.10.0060.01215.63
7.1.00.0070.04019.09
7.0.330.0030.00715.38
7.0.320.0090.00615.24
7.0.310.0070.00415.46
7.0.300.0000.01515.30
7.0.290.0030.00715.36
7.0.280.0040.00715.38
7.0.270.0040.00715.25
7.0.260.0100.00315.38
7.0.250.0090.00915.54
7.0.240.0080.00315.32
7.0.230.0030.01015.10
7.0.220.0070.00315.53
7.0.210.0110.00315.16
7.0.200.0020.00615.82
7.0.190.0030.00615.38
7.0.180.0090.00915.47
7.0.170.0060.01215.45
7.0.160.0000.00915.29
7.0.150.0040.01115.04
7.0.140.0060.03818.72
7.0.130.0100.00315.33
7.0.120.0060.00615.06
7.0.110.0070.00715.18
7.0.100.0060.00315.32
7.0.90.0070.00715.21
7.0.80.0000.01115.41
7.0.70.0060.00915.45
7.0.60.0090.04417.80
7.0.50.0030.03016.82
7.0.40.0060.02517.19
7.0.30.0190.02717.21
7.0.20.0160.02817.09
7.0.10.0050.03117.16
7.0.00.0070.03817.22
5.6.400.0070.00314.70
5.6.390.0030.00914.56
5.6.380.0090.00614.33
5.6.370.0040.00814.75
5.6.360.0080.01214.60
5.6.350.0070.00714.10
5.6.340.0040.00714.28
5.6.330.0030.00914.34
5.6.320.0030.01414.55
5.6.310.0030.00714.34
5.6.300.0040.01114.68
5.6.290.0120.00614.63
5.6.280.0110.03317.85
5.6.270.0070.00714.77
5.6.260.0000.00814.59
5.6.250.0030.01414.10
5.6.240.0060.00914.27
5.6.230.0110.00714.50
5.6.220.0070.00714.44
5.6.210.0080.04117.43
5.6.200.0110.02816.24
5.6.190.0110.03317.44
5.6.180.0140.03217.43
5.6.170.0140.04617.29
5.6.160.0100.04017.44
5.6.150.0070.04016.14
5.6.140.0050.03016.41
5.6.130.0050.04816.34
5.6.120.0090.02817.65
5.6.110.0030.03917.73
5.6.100.0070.03817.82
5.6.90.0100.03717.67
5.6.80.0080.03717.31
5.6.70.0070.00714.21
5.6.60.0060.00814.47
5.6.50.0100.00714.41
5.6.40.0000.01514.20
5.6.30.0040.01114.27
5.6.20.0080.00814.53
5.6.10.0090.00914.10
5.6.00.0030.00614.15
5.5.380.0040.01114.19
5.5.370.0060.00314.26
5.5.360.0080.00814.15
5.5.350.0160.04317.46
5.5.340.0080.02216.05
5.5.330.0050.02817.20
5.5.320.0050.03017.29
5.5.310.0200.04617.26
5.5.300.0070.04216.07
5.5.290.0030.03916.28
5.5.280.0080.03317.52
5.5.270.0090.03817.41
5.5.260.0080.02817.58
5.5.250.0020.04817.53
5.5.240.0060.02117.15
5.5.230.0070.01014.36
5.5.220.0040.00714.10
5.5.210.0130.00614.35
5.5.200.0110.00714.42
5.5.190.0090.00614.10
5.5.180.0060.01214.10
5.5.170.0040.01414.19
5.5.160.0110.00314.31
5.5.150.0100.00314.10
5.5.140.0030.01214.17
5.5.130.0060.00614.34
5.5.120.0040.00714.11
5.5.110.0130.00014.10
5.5.100.0060.00314.30
5.5.90.0040.00814.14
5.5.80.0030.01014.21
5.5.70.0060.00314.10
5.5.60.0000.01114.10
5.5.50.0110.00414.10
5.5.40.0090.00614.20
5.5.30.0040.00414.10
5.5.20.0060.00614.10
5.5.10.0000.00814.10
5.5.00.0060.01014.18
5.4.450.0450.03516.82
5.4.440.0350.03016.69
5.4.430.0480.02816.82
5.4.420.0330.03816.82
5.4.410.0090.02816.42
5.4.400.0170.03216.34
5.4.390.0230.02416.45
5.4.380.0030.03016.37
5.4.370.0100.03016.44
5.4.360.0050.02216.33
5.4.350.0090.02013.08
5.4.340.0040.02313.08
5.4.330.0000.00614.10
5.4.320.0080.02013.32
5.4.310.0060.02213.32
5.4.300.0050.02013.32
5.4.290.0090.01713.32
5.4.280.0050.01913.27
5.4.270.0030.02013.27
5.4.260.0070.01913.27
5.4.250.0070.02213.27
5.4.240.0050.02313.27
5.4.230.0040.02013.27
5.4.220.0050.01913.27
5.4.210.0060.02113.27
5.4.200.0080.01913.27
5.4.190.0030.02013.27
5.4.180.0040.02413.27
5.4.170.0020.02213.27
5.4.160.0050.02113.27
5.4.150.0040.02113.27
5.4.140.0070.02013.11
5.4.130.0020.02313.10
5.4.120.0070.02213.08
5.4.110.0040.02413.08
5.4.100.0070.02113.08
5.4.90.0060.02313.08
5.4.80.0070.02113.08
5.4.70.0060.01913.08
5.4.60.0030.02213.08
5.4.50.0040.01913.08
5.4.40.0030.02113.07
5.4.30.0090.01813.07
5.4.20.0060.02013.07
5.4.10.0060.01913.07
5.4.00.0040.02312.82
5.3.290.0030.04112.80
5.3.280.0050.03912.72
5.3.270.0070.04112.73
5.3.260.0040.04112.73
5.3.250.0070.04012.73
5.3.240.0050.03812.73
5.3.230.0050.03812.72
5.3.220.0090.03412.70
5.3.210.0060.04012.69
5.3.200.0080.03412.69
5.3.190.0070.03712.70
5.3.180.0060.03712.69
5.3.170.0040.03812.69
5.3.160.0080.03412.69
5.3.150.0050.03812.69
5.3.140.0100.03312.68
5.3.130.0050.04012.67
5.3.120.0060.04012.67
5.3.110.0070.03712.67
5.3.100.0040.04012.17
5.3.90.0050.03812.15
5.3.80.0070.03912.14
5.3.70.0050.03812.14
5.3.60.0070.04212.13
5.3.50.0070.04612.07
5.3.40.0060.03612.07
5.3.30.0050.03512.03
5.3.20.0080.03211.82
5.3.10.0030.03611.78
5.3.00.0060.03611.77
5.2.170.0090.0269.27
5.2.160.0030.0319.27
5.2.150.0040.0319.27
5.2.140.0050.0309.27
5.2.130.0070.0269.23
5.2.120.0040.0289.23
5.2.110.0050.0289.24
5.2.100.0020.0309.23
5.2.90.0020.0319.23
5.2.80.0040.0309.23
5.2.70.0010.0349.23
5.2.60.0070.0279.18
5.2.50.0060.0289.15
5.2.40.0010.0339.13
5.2.30.0070.0289.10
5.2.20.0050.0289.09
5.2.10.0060.0299.00
5.2.00.0040.0378.86
5.1.60.0040.0248.16
5.1.50.0020.0278.15
5.1.40.0040.0268.13
5.1.30.0030.0288.48
5.1.20.0030.0318.50
5.1.10.0030.0278.23
5.1.00.0040.0268.23
5.0.50.0060.0186.70
5.0.40.0030.0206.57
5.0.30.0040.0306.38
5.0.20.0030.0206.34
5.0.10.0050.0186.33
5.0.00.0040.0306.32
4.4.90.0040.0144.78
4.4.80.0060.0124.75
4.4.70.0040.0144.76
4.4.60.0030.0154.75
4.4.50.0020.0164.77
4.4.40.0030.0254.71
4.4.30.0020.0164.76
4.4.20.0010.0174.84
4.4.10.0020.0164.85
4.4.00.0060.0224.76
4.3.110.0040.0144.67
4.3.100.0040.0144.67
4.3.90.0020.0154.63
4.3.80.0020.0264.58
4.3.70.0030.0144.63
4.3.60.0020.0154.63
4.3.50.0050.0134.63
4.3.40.0030.0244.54
4.3.30.0030.0153.31
4.3.20.0020.0163.29
4.3.10.0030.0153.24
4.3.00.0130.0237.12

preferences:
61.05 ms | 400 KiB | 5 Q