PHP - List Folders & Files Functions - PHP Source Code

PHP - HOW TO View Info About the Current Directory/Folders/Files via PHP Code

Home Short:

Trying to get information about the current directly you are in via PHP can be a bit confusing with all the various PHP functions related to listing information about the current directory.

For the code examples below, we will pretend we are running the php from a url on our website https://www.vb6code.com/phpcode/examples/code-php-current-directory-file-functions.php

You can test these file/folder functions on your web server by copying and pasting the code below into a text file and saving as .php.

If you have a url and you want to parse the url into its different parts you can use the PHP parse_url function.

We will use the example url https://www.vb6code.com/phpcode/examples/code-php-current-directory-file-functions.php?r=affiliate

First you call the parse_url function, passing the url you want to parse.

S
H
A
R
E