PDA

View Full Version : Return values of include() and require()



DarkReaper
Sun 11th Nov '01, 2:10pm
I've got my website setup right now with 2 index files - content.php and index.php. All the pages except for the main index use content.php?c=pagename. This does a require("/include/$c.inc");. If this fails, it still shows the page up to that point though. How can I check if the file with name $c.inc exists?

Mark Hensler
Sun 11th Nov '01, 2:43pm
Haven't tried this, just a quick thought...


require("my.php") or echo "cant open file";

Chen
Sun 11th Nov '01, 2:43pm
http://www.php.net/manual/en/function.file-exists.php :)

Mark Hensler
Sun 11th Nov '01, 2:53pm
I belive that file_exists() (http://www.php.net/manual/en/function.file-exists.php) takes the full path as the arguement. But I can't really see this anywhere in the docs. :confused: If it does, use realpath() (http://www.php.net/manual/en/function.realpath.php) to get the full system path.

DarkReaper
Sun 11th Nov '01, 3:16pm
Should've deleted this. About 20 minutes after posting I realized I could use file_exists(), and it works :)

http://www.unrealtournament.org/content.php?c=dlkjfhsjkdf
http://www.unrealtournament.org/content.php?c=cheats

Mark Hensler
Mon 12th Nov '01, 5:17am
Does it use system paths?
Or can you give it relative paths?

(I'm not sure of the scope)