3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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.2.0
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.3.22 - 5.6.28
Fatal error: Using $this when not in object context in /in/LinS1 on line 16
Process exited with code 255.