Get page name in php
Asked 9 years, 10 months ago Show Viewed 354k times I've a file called
So I want something like
I don't want to declare unnecessary GET variables just for doing this...
Samuel Liew♦ 73.6k106 gold badges156 silver badges238 bronze badges asked Oct 23, 2012 at 14:36
0 You can use
answered Oct 23, 2012 at 14:37
Mr. AlienMr. Alien 149k33 gold badges288 silver badges272 bronze badges 5
So
should do it.
answered Oct 23, 2012 at 14:42
AmykateAmykate 4855 silver badges8 bronze badges 0 Not the answer you're looking for? Browse other questions tagged php or ask your own question.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters To get the current page URL, PHP provides a superglobal variable $_SERVER. The $_SERVER is a built-in variable of PHP, which is used to get the current page URL. It is a superglobal variable, means it is always available in all scope. If we want the full URL of the page, then we'll need to check the protocol (or scheme name), whether it is https or http. See the example below: Output Note: The isset() function is used here to check whether HTTPS is enabled or not. It checks whether a variable exists or not.Or, we can also get the full URL of current page using another way given in the next example. Output To get only name of the current page opened at browser, see the below example: Output For Videos Join Our Youtube Channel: Join Now Feedback
Help Others, Please ShareTopic: PHP / MySQLPrev|Next Answer: Use the PHP $_SERVER Superglobal VariableYou can use the Also if you want full URL of the page you'll need to check the scheme name (or protocol), whether it is
Related FAQHere are some more FAQ related to this topic:
How to get website name in PHP?$url = "http://"; // Append the host(domain name, ip) to the URL. $url. = $_SERVER['HTTP_HOST'];. $curPageName = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);. What is $_ GET page?PHP $_GET is a PHP super global variable which is used to collect form data after submitting an HTML form with method="get". $_GET can also collect data sent in the URL. Assume we have an HTML page that contains a hyperlink with parameters:
How do I get a full URL?Just right-click in Chrome's address bar select “Always show full URLs” to make Chrome show full URLs. Chrome will now always show the full URL of every web address you open. To disable this feature, right-click in the address bar again and uncheck it.
How can I get the last part of a URL in PHP?')) $uri = substr($uri, 0, strpos($uri, '? ')); $url = trim($uri, '/');
|