how to know what files were required/include?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

how to know what files were required/include?

Post by Cruzado_Mainfrm »

i don't have any coding yet, but my question is, how can i know what files were required/included in a php page by using include or require?
User avatar
steedvlx
Forum Contributor
Posts: 122
Joined: Wed Jun 11, 2003 10:54 pm
Location: Osaka, Japan

Post by steedvlx »

Hi,

If I understand your question (which, admittedly is not a certainty) You are looking for the file names that were included/required to create an output page that I guess you are looking at.

One of the many beauties of PHP is that this is impossible unless you have access to the web-server's root and can get to the pre-server source code for that page. [In that case, what you are looking for is before the <HEAD> tag in the source code.]

All of the include and require directives are pre-processed by the server and there is no client-side output associated with the directives themselves although the included/required code itself does create HTML output.


PHP...Gotta love it.

Sorry if I didn't understand your question properly.

-----------------------
SteedVLX
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

i understood that php won't let you know because of possible security problems.. right? then i guess i will have to do something like this:

Code: Select all

<?php

$is_page_one_loaded = (@include 'mypage.php') ? true: false;

?>
is that right?
User avatar
steedvlx
Forum Contributor
Posts: 122
Joined: Wed Jun 11, 2003 10:54 pm
Location: Osaka, Japan

Post by steedvlx »

That is a little out of my ballpark. Sorry.

But, IMHO if you have the session variable ($is_page_one_loaded) registered, and you set its value to true within the included script, then it will work just fine.

I Think I'll try it myself when I get a chance.

Anybody else?

---------------------------
SteedVLX
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

if your goal is to make sure something is loaded you can use
include_once() and require_once()

But, if you need this it sort of proves that the programming methods/layout etc is not very good, the structure and such should be in a controlled way.. Very understandable if you are hacking a couple of different scripts/programs together or similar.
Post Reply