473,734 Members | 6,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get pagename from the URL in php

245 New Member
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 18354
Markus
6,050 Recognized Expert Expert
Check out $_SERVER - PHP_SELF may be what you're looking for.
Mar 27 '09 #2
Amzul
130 New Member
try parse_url() http://www.php.net/manual/en/function.parse-url.php
Mar 27 '09 #3
neovantage
245 New Member
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 New Member
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 Recognized Expert Moderator Expert
you can check out the $_SERVER variables when you call phpinfo().
Mar 27 '09 #6
neovantage
245 New Member
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 Recognized Expert Moderator Expert
get all characters after the last "/". strrpos() may be useful for that.
Mar 28 '09 #8
pbmods
5,821 Recognized Expert Expert
Try running basename() on the path.

http://php.net/basename
Mar 28 '09 #9
neovantage
245 New Member
Thank you very much. it resolved now
Mar 29 '09 #10

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

Similar topics

4
2477
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 Pmw.Notebook. There are quite a few lists and dicts which were to be changed and I wasn't successful in the first try. However, if nobody has ever done this, I'd have to rebuild the whole page after deleting/adding. I really hope there's an other way...
3
1559
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 appropriate page on the new site?
4
2452
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 lastpage and the actual page, this method (or property) return incorrect values: "Page1.asp" and "" Why? Martin
1
2049
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 the development machine using vs.net 2003, running quite well. The program has been built on the dev machine, and all files except for the sql/server files exist in one directory under inetpub\wwwroot. I think that IIS is properly configured,...
3
1286
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 inherit from this base class What I would like to happen is that the code in the base class be called first (maybe in the Page_Load, but I'm not sure) to do the checking. My code
3
2409
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
1282
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 using ADO as it is a lot easier than ADO.NET. (Note: I have an ADO class that I can call on any webpage and get the result with one line of code...could not get anything to work in a similar manner in ADO.NET) Now here is my question, I run...
5
3693
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 for repeated html im using the external js, i mean the TOP, BOTTOM they are repeated in every page, so i include them as functions in the external js and call them. Why it doesn't work?
1
1210
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 David McCarter''''s .NET Coding Standards available at: http://www.cafepress.com/geekmusicart.1654787045
0
8957
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8783
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9321
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9193
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8194
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectóplanning, coding, testing, and deploymentówithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6043
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.