ahsn Posted May 29, 2013 Share Posted May 29, 2013 I can make php read a particular file with readfile() function when needed, but how do I make php read a folder of html files. Because we know a full website has many html pages along with css files. I just want to load a site of many html pages when a condition is fulfilled ,i.e. after successful login. Could anyone please tell me how do I do that? Quote Link to comment https://forums.phpfreaks.com/topic/278564-how-to-make-php-read-a-folder/ Share on other sites More sharing options...
requinix Posted May 29, 2013 Share Posted May 29, 2013 glob and scandir are the easiest ways to get an array of files in a directory. glob() can filter it by a filename pattern too so you could glob("/path/to/directory/*.html"). Quote Link to comment https://forums.phpfreaks.com/topic/278564-how-to-make-php-read-a-folder/#findComment-1433033 Share on other sites More sharing options...
ahsn Posted May 30, 2013 Author Share Posted May 30, 2013 @requinix, thanks for help, but couldn't solve. If I run that code, it shows a empty page. But I have 3 html files and a css file linked to each other in a folder named 'dd' and I would like to make php show my complete site in browser when I run index.html file.Is there a way to do that? Quote Link to comment https://forums.phpfreaks.com/topic/278564-how-to-make-php-read-a-folder/#findComment-1433180 Share on other sites More sharing options...
requinix Posted May 30, 2013 Share Posted May 30, 2013 I didn't give you any code. Run what, exactly? Quote Link to comment https://forums.phpfreaks.com/topic/278564-how-to-make-php-read-a-folder/#findComment-1433241 Share on other sites More sharing options...
ahsn Posted May 30, 2013 Author Share Posted May 30, 2013 I mean, I used (in different ways): glob("/path/to/directory/*.html") to load the complete site; but couldn't Quote Link to comment https://forums.phpfreaks.com/topic/278564-how-to-make-php-read-a-folder/#findComment-1433270 Share on other sites More sharing options...
requinix Posted May 30, 2013 Share Posted May 30, 2013 That alone won't do it. It doesn't even have a semicolon to end the statement, and if it did it still wouldn't do anything. You have to write code. You can use that glob() thing in it but you still have to write a lot (relatively) more around it before anything will work. Quote Link to comment https://forums.phpfreaks.com/topic/278564-how-to-make-php-read-a-folder/#findComment-1433271 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.