|
Posted by Norman Peelman on 05/13/07 03:24
Alan Jones wrote:
> On Sat, 12 May 2007 00:23:04 -0400, Norman Peelman
> <npeelman@cfl.rr.com> wrote:
>
>> Alan Jones wrote:
>>> Hello everyone, any help would be greatly appreciated. :)
>>>
>>> What I'm trying to do may not be advisable, but here goes...
>>>
>>> I want a page named signature.php to appear conditionally as
>>> an include within another include so that it will, for example,
>>> appear in index.php but not in other result pages that use the
>>> same top level include.
>>>
>>> The method would need to determine what page it is inside of
>>> during each given instance. I guess something like...
>>>
>>> if page is index.php then include file else do nothing
>>>
>>> A 'nested conditional' seems obvious but I don't know how to
>>> create an argument that checks the result page file name or
>>> otherwise id's that parent page.
>>>
>>> Obviously, I'm new to PHP and my understanding of basic
>>> programming is very limited. I'm also new to the group. I hope
>>> to learn quickly, and I look forward to helping others in the
>>> future.
>> I think you're looking for the $_SERVER super_global variable. Check
>> http://www.php.net/reserved.variables $_SERVER['REQUEST_URI'] holds the
>> info you're looking for.
>>
>> Norm
>
> Thank you very much for the help. :) I'll give your recommendation
> a run thru, but is there a way to make basename, or a similar
> function, simply return the filename of the parent page; the page
> the include is in? Thanks again, I really appreciate any help I can
> get.
>
I'm sorry, maybe I don't understand what you're asking for...
doesn't $_SERVER['REQUEST_URI'] do what you need?
if (($_SERVER['REQUEST_URI'] == '/index.php') ||
($_SERVER['REQUEST_URI'] == '/'))
{
include('signature.php');
}
I found that $_SERVER['REQUEST_URI'] will return '/' at the top of the
domain name. In other words '/' should be equal to whatever your default
file is for the domain in question.
Norm
Navigation:
[Reply to this message]
|