We open these directories through the opendir() function again. We then use an if statement to check to see which of these files are directories. We open the directory and use a while loop to loop through allįiles in the directory. Now to say all the files in the home directory, we use the PHP scandir() function. So we create a variable called $homedirectory and make itĮqual to "." This gives us the home directory. So first, if you want to go all through the files on your website, the best way to do so is through the home directory. We'll now go over all the code so that you can understand. If the file is an HTML file, it converts the html file to The code loops through every file in the home directory and every file in any subdirectory of the home directory. Only use it and upload it to your website if you actually want to convert every HTML file to a PHP file. Of your website, it will convert every HTML page to a PHP page.
![pages file extension pages file extension](https://appletoolbox.com/wp-content/uploads/2012/08/Windows-PC-Hide-extensions-uncheck.jpg)
If you copy the above code, save it as a PHP file, and upload it to the root directory So this code shown above is very powerful. The PHP code to loop all files in your home directory and all files in the subdirectories of the So how can you loop through all the files in your website that you want to?
#Pages file extension upgrade
So let's say you want to upgrade your website from static HTML to dynamic PHP pages, which offer much Let's convert HTML files (.html) to PHP files (.php). PHP Script to Convert HTML Files (.html) to PHP Files (.php) Files Yes, this is the power of a server side language such as PHP. php, changing the file from an HTML file to a PHP file.Īnd we can convert any file extension from one to another. When it loops through each file in the directory, we can check the file extension of thatįile. Once it access a directory, it can loop throughĮach file in the directory. It can access and manipulate theīackend of a website such as the directories that comprise a website. If you have hundreds or thousands of files in a directory, this could save hours, days, or weeks of manualīasically, the gist of it is that PHP is a powerful server side language.
![pages file extension pages file extension](https://www.easepdf.com/images/others/pages-file-rename.png)
The point is, you can change any file extension with PHP asp files.Īnd the list goes on and on and on and on.
#Pages file extension how to
In this article, we show how to write a PHP script which can convert any web page file extension to another PHP Script to Convert Any Web Page File Extension