Now that we’ve talked about files, it’s time to talk about directory access. PHP has a whole variety of functions designed just for this! Here are the important ones:
- chdir($dir): Change working directory
- $dir = getcwd(): Get working directory
- mkdir($dir, [$permission], [$recursive]): Create a new directory with permission model (in octal) $permission
- is_dir($directory): Check if path is an actual directory
- chmod($file, $permission): Change permission of a file/directory with a permission model (also in octal)
- chgrp($file, $group): Change group ownership of a file/directory
- chown($file, $name): Change ownership of a file/directory
- $array = scandir($folder): Return a list of files/directories in the specified folder
Network Access
Basic network access is performed very similarly to file access.
$file = fopen(“http://www.google.com”);
-
$content = "";
-
-
while ($temp = fread($file, 1000))
-
$content .= $temp;
-
-
fclose($file);
Obviously, you cannot use ALL the same functions as for example, you cannot write to a website stream.
This is the most basic form of access, you can also use curl (which I love) for a more advanced approach.
Tomorrow I’ll cover Advanced Streaming.

