3v4l.org

run code in 300+ PHP versions simultaneously
<?php // no separator $dir = '/tmp/'; ini_set('open_basedir', $dir); print("ini_set to ".$dir."\n"); $fp = fopen('/tmp/hhvm-openbasedir-test', 'w'); if ($fp) { print("Opened!\n"); fclose($fb); } else print("Failed to open\n"); // with separator $dir = dirname(PHP_BINARY); ini_set('open_basedir', $dir); print("ini_set to ".$dir."\n"); $fp = fopen('/tmp/hhvm-openbasedir-test', 'w'); if ($fp) { print("Opened!\n"); fclose($fb); } else print("Failed to open\n"); // with separator $dir = '/tmp/'.PATH_SEPARATOR.dirname(PHP_BINARY); ini_set('open_basedir', $dir); print("ini_set to ".$dir."\n"); $fp = fopen('/tmp/hhvm-openbasedir-test', 'w'); if ($fp) { print("Opened!\n"); fclose($fb); } else print("Failed to open\n");
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
ini_set to /tmp/ Opened! Warning: Undefined variable $fb in /in/7DmQe on line 10 Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, null given in /in/7DmQe:10 Stack trace: #0 /in/7DmQe(10): fclose(NULL) #1 {main} thrown in /in/7DmQe on line 10
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
ini_set to /tmp/ Opened! Notice: Undefined variable: fb in /in/7DmQe on line 10 Warning: fclose() expects parameter 1 to be resource, null given in /in/7DmQe on line 10 ini_set to /usr/bin Opened! Notice: Undefined variable: fb in /in/7DmQe on line 21 Warning: fclose() expects parameter 1 to be resource, null given in /in/7DmQe on line 21 ini_set to /tmp/:/usr/bin Opened! Notice: Undefined variable: fb in /in/7DmQe on line 31 Warning: fclose() expects parameter 1 to be resource, null given in /in/7DmQe on line 31
Output for 5.3.0 - 5.3.29
ini_set to /tmp/ Opened! Notice: Undefined variable: fb in /in/7DmQe on line 10 Warning: fclose() expects parameter 1 to be resource, null given in /in/7DmQe on line 10 Notice: Use of undefined constant PHP_BINARY - assumed 'PHP_BINARY' in /in/7DmQe on line 15 ini_set to . Opened! Notice: Undefined variable: fb in /in/7DmQe on line 21 Warning: fclose() expects parameter 1 to be resource, null given in /in/7DmQe on line 21 Notice: Use of undefined constant PHP_BINARY - assumed 'PHP_BINARY' in /in/7DmQe on line 25 ini_set to /tmp/:. Opened! Notice: Undefined variable: fb in /in/7DmQe on line 31 Warning: fclose() expects parameter 1 to be resource, null given in /in/7DmQe on line 31
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
ini_set to /tmp/ Opened! Notice: Undefined variable: fb in /in/7DmQe on line 10 Warning: fclose(): supplied argument is not a valid stream resource in /in/7DmQe on line 10 Notice: Use of undefined constant PHP_BINARY - assumed 'PHP_BINARY' in /in/7DmQe on line 15 ini_set to . Opened! Notice: Undefined variable: fb in /in/7DmQe on line 21 Warning: fclose(): supplied argument is not a valid stream resource in /in/7DmQe on line 21 Notice: Use of undefined constant PHP_BINARY - assumed 'PHP_BINARY' in /in/7DmQe on line 25 ini_set to /tmp/:. Opened! Notice: Undefined variable: fb in /in/7DmQe on line 31 Warning: fclose(): supplied argument is not a valid stream resource in /in/7DmQe on line 31
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.3
ini_set to /tmp/ Opened! Notice: Undefined variable: fb in /in/7DmQe on line 10 Warning: fclose(): supplied argument is not a valid stream resource in /in/7DmQe on line 10 Notice: Use of undefined constant PHP_BINARY - assumed 'PHP_BINARY' in /in/7DmQe on line 15 ini_set to . Opened! Notice: Undefined variable: fb in /in/7DmQe on line 21 Warning: fclose(): supplied argument is not a valid stream resource in /in/7DmQe on line 21 Notice: Use of undefined constant PHP_BINARY - assumed 'PHP_BINARY' in /in/7DmQe on line 25 ini_set to /tmp/:. Opened! Notice: Undefined variable: fb in /in/7DmQe on line 31 Warning: fclose(): supplied argument is not a valid stream resource in /in/7DmQe on line 31

preferences:
284.36 ms | 403 KiB | 468 Q