472,371 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

how to get pagename from the URL in php

245 100+
Hey all,
i want to get the page name from the url. e.g.
My URL is
http://bytes.com/newthread.php

and i want to get page name newthread.php. How can i do that? Kindly help me out to sort out my problem.

Thanks in Advance

kind regards,
Mohsin Rafique
Mar 27 '09 #1
10 18084
Markus
6,050 Expert 4TB
Check out $_SERVER - PHP_SELF may be what you're looking for.
Mar 27 '09 #2
Amzul
130 100+
try parse_url() http://www.php.net/manual/en/function.parse-url.php
Mar 27 '09 #3
neovantage
245 100+
Sir both the things i know but i just want to get the page name only! not the whole URL or path or host name
Mar 27 '09 #4
Amzul
130 100+
Expand|Select|Wrap|Line Numbers
  1. $url ='http://bytes.com/newthread.php';
  2. $data = parse_url($url);
  3. echo $data['path'];
Mar 27 '09 #5
Dormilich
8,658 Expert Mod 8TB
you can check out the $_SERVER variables when you call phpinfo().
Mar 27 '09 #6
neovantage
245 100+
Sir in my case, my path is "rage/biz/site/products.php" and my url is "http://localhost/rage/biz/site/products.php"

As i am running application on my local machine by creating sub directories at the root folder. So in this case how can i get the pagename?
Mar 28 '09 #7
Dormilich
8,658 Expert Mod 8TB
get all characters after the last "/". strrpos() may be useful for that.
Mar 28 '09 #8
pbmods
5,821 Expert 4TB
Try running basename() on the path.

http://php.net/basename
Mar 28 '09 #9
neovantage
245 100+
Thank you very much. it resolved now
Mar 29 '09 #10
Found this on another website, gets all characters after last "/" this equals to pagename, for example it will echo "index.php" from

http://mywebsite.com/folder1/folder2/index.php

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function curPageName() {
  3.  return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
  4. }
  5.  
  6. echo "The current page name is ".curPageName();
  7. ?>
  8.  
Nov 17 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: F. GEIGER | last post by:
Hi again, I'd like to rename a page of a notebook. Deleting the page and adding a new one is not really an option, because the page is filled with other controls already. So I looked into...
3
by: Dave | last post by:
I am moving a web to a new address. The old address will be shut down in several weeks. Is there a way to automatically redirect users who come to the old site in these last few weeks to the...
4
by: Martin | last post by:
Hi, From Page1.asp, I use "Server.transfer" to "REDIRECT" to another asp page (page2.asp), in page2.asp I use Request.ServerVariables("URL") and Request.ServerVariables("REFERER") to get the...
1
by: Bent Biker | last post by:
This message occurs when browsing to the start of an asp.net program that has been transferred to a machine with the dotnet framework 1.1, IIS 5.1, XP/Pro, and SQL/Server. It is is operational on...
3
by: Dave | last post by:
Hi, I want to create a base Webform where I want to put code to check if the logged on user is allowed to view the page. I want to put this code in once place and have all secured webforms...
3
by: sasikumar | last post by:
Can i hide page name (default.aspx) appearing in addressbar and status bar of internet explorer or firefox. if yes please tell me vb.net code for that.
2
by: Guru | last post by:
I have a web application where people have to login to use the system. I have my own login system and a database which stores login details. ASP.NET pages are written with VB as code behind. I am...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
1
by: =?Utf-8?B?ZG90TmV0RGF2ZQ==?= | last post by:
I think you can actually get this from the Request object. It might be in the ServerVariables collection. David -- ====================================== David McCarter www.dotNetTips.com...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.