xref: /PHP-7.4/ext/standard/tests/file/006_basic.phpt (revision 8b5c3511)
1--TEST--
2Test fileperms() & chmod() functions: basic functionality
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip Not on Windows');
7}
8require __DIR__ . '/../skipif_root.inc';
9?>
10--FILE--
11<?php
12/*
13  Prototype: int fileperms ( string $filename );
14  Description: Returns the permissions on the file, or FALSE in case of an error
15
16  Prototype: bool chmod ( string $filename, int $mode );
17  Description: Attempts to change the mode of the file specified by
18    filename to that given in mode
19*/
20$path = __DIR__;
21
22echo "*** Testing fileperms(), chmod() with files and dirs ***\n";
23fopen($path."/perm.tmp", "w");
24var_dump( chmod($path."/perm.tmp", 0755 ) );
25printf("%o", fileperms($path."/perm.tmp") );
26echo "\n";
27clearstatcache();
28
29mkdir($path."/perm");
30var_dump( chmod( $path."/perm", 0777 ) );
31printf("%o", fileperms($path."/perm") );
32echo "\n";
33clearstatcache();
34
35echo "Done\n";
36?>
37--CLEAN--
38<?php
39unlink(__DIR__."/perm.tmp");
40rmdir(__DIR__."/perm");
41?>
42--EXPECT--
43*** Testing fileperms(), chmod() with files and dirs ***
44bool(true)
45100755
46bool(true)
4740777
48Done
49