3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Piwik - free/libre analytics platform * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ namespace Piwik; use Piwik\Tests\Framework\Mock\File; function filesize($filename) { if (File::getFileSize() !== null) { return File::getFileSize(); } return \filesize($filename); } function file_exists($filename) { if (File::getFileExists() !== null) { return File::getFileExists(); } return \file_exists($filename); } class Test { public static function tester() { return self::getFileSize(1024*1024*101); } } public static function getFileSize($pathToFile, $unit = 'B') { $unit = strtoupper($unit); $units = array('TB' => pow(1024, 4), 'GB' => pow(1024, 3), 'MB' => pow(1024, 2), 'KB' => 1024, 'B' => 1); if (!array_key_exists($unit, $units)) { throw new Exception('Invalid unit given'); } if (!file_exists($pathToFile)) { return; } $filesize = filesize($pathToFile); $factor = $units[$unit]; $converted = $filesize / $factor; return $converted; } namespace Piwik\Tests\Framework\Mock; class File { static $filesize = null; static $fileExists = null; public static function getFileSize() { return self::$filesize; } public static function setFileSize($filesize) { self::$filesize = $filesize; } public static function reset() { self::$filesize = null; self::$fileExists = null; } public static function getFileExists() { return self::$fileExists; } public static function setFileExists($exists) { self::$fileExists = $exists; } } File::setFileSize(1024 * 1024 * 101); File::setFileExists(true); var_dump(\Piwik\Test::tester());
Output for 5.4.0 - 5.4.35
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/npq4d on line 35
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_PUBLIC in /in/npq4d on line 35
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/npq4d on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/npq4d on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/npq4d on line 8
Process exited with code 255.

preferences:
213.72 ms | 1394 KiB | 125 Q