[SOLVED] getting page file name.

This is a discussion on "[SOLVED] getting page file name." within the PHP Forum section. This forum, and the thread "[SOLVED] getting page file name. are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Nov 11th, 2007, 16:27
Junior Member
Join Date: Jul 2007
Location: Bournemouth, UK
Age: 15
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] getting page file name.

hello, I have a file called lol.php - header.php is included into lol.php. header.php contains the script, and it needs to be here for asthetical reasons, and the function. I need to get the page name of lol.php from header.php. is this possible?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 11th, 2007, 17:23
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: getting page file name.

That was confusing and made little sense.
Post your code.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Nov 11th, 2007, 17:26
Junior Member
Join Date: Jul 2007
Location: Bournemouth, UK
Age: 15
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: getting page file name.

sorry, im very bad at explaining.

I have made an online example.

http://www.killerchutney.com/lol.php (aptly named ) heres the page I need to detect through header.php.

heres the code in header.php
Code: Select all
<div <?php
    function getpage() {
        $this_page = $_SERVER['PHP_SELF'];
         return $this_page;}
    
    if (getpage() == 'index.php'){
        echo ('id="content"');}
    
    elseif (getpage() == 'lol.php'){
        echo ('style="background-color:#ff00f6;"');}
        
    elseif (getpage() == '/templates/header.php'){
        echo ('style="background-color:#3cff00;"');}
    
    else{ echo ('style="background-color:#000000;"'); }?>>
if the script is working correctly, the background color of lol.php should be pink. If it is working incorrectly then it should be green (as it is now).

you can see in the left corner of the green div /templates/header.php - the include file name. but in the address bar it says http://www.killerch.../lol.php I need it to detect the URL shown in the address bar, instead the URL of the include.

Last edited by KillerChutney; Nov 11th, 2007 at 17:29.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Nov 12th, 2007, 03:22
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: getting page file name.

Hmm, why do you want to detect a page? Can you describe your full goal. I have never come across a reason to detect another page unless there is some form or other data that needs to be validated...
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Nov 12th, 2007, 04:15
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: getting page file name.

WHy don't you create a global variable in the lol.php with the file name before you include the file?

The variable will hold the $_SERVER['php_self'] of lol.php and that way, because header.php gets all the variables declared when it is included, it has access to the calling file name.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Nov 12th, 2007, 16:07
Junior Member
Join Date: Jul 2007
Location: Bournemouth, UK
Age: 15
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Re: getting page file name.

ah! ok thank you this coupled with an answer from another forum it works perfectly now thank you once again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Nov 12th, 2007, 16:17
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: getting page file name.

No problems
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sql file problem longstand Databases 1 Oct 27th, 2007 17:09
How to link HTML page to CSS file winwin Web Page Design 18 Dec 21st, 2006 09:46
upload file submitted from .html page simonneaves ASP.NET Forum 0 Jun 2nd, 2006 17:08
Delete file in password protected page. SweetLou Classic ASP 4 Jan 7th, 2006 21:15
file field in ASP page lameneural Classic ASP 18 Dec 8th, 2005 11:46


All times are GMT. The time now is 14:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42