dudebrodude Posted November 11, 2013 Share Posted November 11, 2013 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>PHP</title> </head> <body> <?php $dir = opendir("files"); while(false !== ($file = readdir($dir))){ while (!feof($file)) { $name = fgets($file, 1024); } } closedir($handle); ?> </body> </html> The code won't recognise the opendir, readdir, feof, fgets, what am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Barand Posted November 11, 2013 Share Posted November 11, 2013 try if it recognizes fopen before trying to read from a file Quote Link to comment Share on other sites More sharing options...
dudebrodude Posted November 11, 2013 Author Share Posted November 11, 2013 It recognises fopen everywhere, just not these. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 11, 2013 Share Posted November 11, 2013 The point is you have not used fopen on the file before using feof() or fgets() Quote Link to comment Share on other sites More sharing options...
dudebrodude Posted November 11, 2013 Author Share Posted November 11, 2013 It is supposed to use readdir to open each file in the directory and read it, but readdir and opendir are not recognised. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 11, 2013 Share Posted November 11, 2013 No, it isn't. It is supposed to use readdir() to get the filenames which you then have to open then read. As I said Quote Link to comment Share on other sites More sharing options...
dudebrodude Posted November 11, 2013 Author Share Posted November 11, 2013 ok, but readdir and opendir are still not working... Quote Link to comment Share on other sites More sharing options...
Barand Posted November 11, 2013 Share Posted November 11, 2013 Are you sure the path "files" is correct? Quote Link to comment Share on other sites More sharing options...
dudebrodude Posted November 11, 2013 Author Share Posted November 11, 2013 (edited) Yes they are correct, but on Notepad++ it is not recognising them as code like with fopen or while (fopen, while, false etc. are all blue, while opendir, readdir, fgets, feof are just black like normal text.) Edited November 11, 2013 by dudebrodude Quote Link to comment Share on other sites More sharing options...
kicken Posted November 11, 2013 Share Posted November 11, 2013 Then your editor's list of functions is probably out of date or something. Unless you are actually getting an error from PHP itself when running the script, then there is no problem. Just because your editor doesn't properly highlight something does not mean the code is incorrect or somehow broken. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted November 11, 2013 Share Posted November 11, 2013 Go to Settings > Style Configurator and select Language: PHP and Style: WORD, then add them under User-defined keywords. Notepad++ is a notepad with some scripting features, not a PHP editor. Quote Link to comment 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.