3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCode($account, $domain, $sampleRate) { $result = '<script type="text/javascript">' . PHP_EOL . '(function (i, s, o, g, r, a, m) {' . PHP_EOL . 'i[\'GoogleAnalyticsObject\'] = r;' . PHP_EOL . 'i[r] = i[r] || function () {' . PHP_EOL . '(i[r].q = i[r].q || []).push(arguments)' . PHP_EOL . '}, i[r].l = 1 * new Date();' . PHP_EOL . 'a = s.createElement(o),' . PHP_EOL . 'm = s.getElementsByTagName(o)[0];' . PHP_EOL . 'a.async = 1;' . PHP_EOL . 'a.src = g;' . PHP_EOL . 'm.parentNode.insertBefore(a, m)' . PHP_EOL . '})(window, document, \'script\', \'//www.google-analytics.com/analytics.js\', \'ga\');' . PHP_EOL . 'ga(\'create\', \'' . $this->account . '\',' . PHP_EOL . '{' . PHP_EOL . '\'cookieDomain\': \'' . $this->domain . '\',' . PHP_EOL . '\'siteSpeedSampleRate\': \'' . $this->sampleRate .'\'' . PHP_EOL . '}' . PHP_EOL . ');' . PHP_EOL . 'ga(\'send\', \'pageview\');' . PHP_EOL . '</script>'; return $result; } echo getCode('1', 'livejasmin.com', 100);
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Using $this when not in object context in /in/LinS1:16 Stack trace: #0 /in/LinS1(28): getCode('1', 'livejasmin.com', 100) #1 {main} thrown in /in/LinS1 on line 16
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Using $this when not in object context in /in/LinS1 on line 16
Process exited with code 255.

preferences:
190.97 ms | 401 KiB | 194 Q