Jump to content

Recommended Posts

Is there a way to get the page name that the function is in ..rather than the page the user is viewing?

 

So example:

 

index.php

// code here
include 'bleh.php';
//code

 

and in the bleh.php has a function to get the name of that file which would return "bleh.php".

 

Because at moment because its included in index.php im getting a result of index.php as a returned variable for function:

strtolower($_SERVER['PHP_SELF'])

 

What function should I use?

Link to comment
https://forums.phpfreaks.com/topic/133514-get-page-name/
Share on other sites

I'm not sure if this is possible.  But consider this, if you are including the file that means at some point you explicitly know the name of the file you are including.  So either save the name of the files you are including, or approach the problem you are having from a different angle.

 

Just a suggestion.

Link to comment
https://forums.phpfreaks.com/topic/133514-get-page-name/#findComment-694442
Share on other sites

Yeah use __FILE__

 

The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances

 

Ignore my asshole comment from before :)

 

$this_file_name = basename(__FILE__);

Link to comment
https://forums.phpfreaks.com/topic/133514-get-page-name/#findComment-694460
Share on other sites

Sometime ago...

 

I had a page /menu/index.php. In this page, I used the normal html layout, so, I a gave the page a title

<head>

<title>menu</title>

</head>

 

Everytime i included it, the overall page beocomes called 'menu'

 

So perhaps this is what you should do, include the page first thing, then echo the page title

Link to comment
https://forums.phpfreaks.com/topic/133514-get-page-name/#findComment-694551
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.