3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.1.0 - 5.6.28, 7.0.0 - 7.1.0
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 hhvm-3.12.0
Fatal error: File not found: dauth.php in /in/Ha6aa on line 6
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.2 - 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