3v4l.org

run code in 300+ PHP versions simultaneously
<?php function write_log($txt) { file_put_contents("put_log.txt", $txt); chmod("put_log.txt", 0666); } require 'dauth.php'; // customize the following defines:- define('AUTH_REALM', 'myserver/mydirectory'); define('URL_BASE', 'http://myserver/mydirectory'); /* --- The following sample authorization function uses an array of user names and passwords defined and fixed here. An actual implementation might read the array from an external resource. The use of an ArrayIterator makes it moderately easy to extend this mechanism. --- */ function authorize() { $auth = new authorizer(AUTH_REALM, new ArrayIterator(array('user1' => 'password1', 'user2' => 'password2'))); $auth->check(); // dies if not OK } function puterror($status, $body, $log = FALSE) { header ("HTTP/1.1 $status"); if ($log) write_log($log); die("<html><head><title>Error $status</title></head><body>$body</body></html>"); } function putfile() { $f = pathinfo($fname = $_SERVER['REQUEST_URI']); if ($f['extension'] != 'html') puterror('403 Forbidden', "Bad file type in $fname"); $f = fopen($fname = $f['basename'], 'w'); if (!$f) puterror('409 Create error', "Couldn't create file"); $s = fopen('php://input', 'r'); // read from standard input if (!$s) puterror('404 Input Unavailable', "Couldn't open input"); while($kb = fread($s, 1024)) fwrite($f, $kb, 1024); fclose($f); fclose($s); chmod($fname, 0666); $fname = URL_BASE . $fname; header("Location: $fname"); header("HTTP/1.1 201 Created"); echo "<html><head><title>Success</title></head><body>"; echo "<p>Created <a href='$fname'>$fname</a> OK.</p></body></html>"; } if ($_SERVER['REQUEST_METHOD'] != 'PUT') header("HTTP/1.1 403 Bad Request"); else { authorize(); putfile(); // uncommment the next line to debug misbehaviour //write_log(date('c') . "\n" . $_SERVER['REQUEST_URI'] . "\nStatus: $retcode; } ?>
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Warning: require(): open_basedir restriction in effect. File(dauth.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Ha6aa on line 6 Warning: require(dauth.php): Failed to open stream: Operation not permitted in /in/Ha6aa on line 6 Fatal error: Uncaught Error: Failed opening required 'dauth.php' (include_path='.:') in /in/Ha6aa:6 Stack trace: #0 {main} thrown in /in/Ha6aa on line 6
Process exited with code 255.
Output for 8.0.13
Warning: require(dauth.php): Failed to open stream: No such file or directory in /in/Ha6aa on line 6 Fatal error: Uncaught Error: Failed opening required 'dauth.php' (include_path='.:') in /in/Ha6aa:6 Stack trace: #0 {main} thrown in /in/Ha6aa on line 6
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.3.32 - 7.3.33, 7.4.26, 7.4.33
Warning: require(dauth.php): failed to open stream: No such file or directory in /in/Ha6aa on line 6 Fatal error: require(): Failed opening required 'dauth.php' (include_path='.:') in /in/Ha6aa on line 6
Process exited with code 255.
Output for 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32
Warning: require(): open_basedir restriction in effect. File(dauth.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/Ha6aa on line 6 Warning: require(dauth.php): failed to open stream: Operation not permitted in /in/Ha6aa on line 6 Fatal error: require(): Failed opening required 'dauth.php' (include_path='.:') in /in/Ha6aa on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5
Warning: main(dauth.php): failed to open stream: No such file or directory in /in/Ha6aa on line 6 Fatal error: main(): Failed opening required 'dauth.php' (include_path='.:') in /in/Ha6aa on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: main(dauth.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/Ha6aa on line 6 Fatal error: main() [http://www.php.net/function.main]: Failed opening required 'dauth.php' (include_path='.:') in /in/Ha6aa on line 6

preferences:
230.88 ms | 402 KiB | 329 Q