How can get the current path in PHP [duplicate] - php

This question already has answers here:
How to get URL of current page in PHP [duplicate]
(5 answers)
Closed 9 years ago.
How can I return the path of the current page including whats after ?
So for example I am this link
localhost/site1/index.php?view=10&user=5
I want to return this value "index.php?view=10&user=5"
How can I do that using PHP?
I thought $_SERVER['SCRIPT_NAME'] do this but SCRIPT_NAME is returing index.php

$_SERVER['QUERY_STRING']
and
$_SERVER['REQUEST_URI']
request uri will give you full uri, you can manipulate it to get the last path
as #Mathieu Imbert said, get curious. Inspect everything $_SERVER gives you either by var_dump or by reading documentation i linked to in a comment

Related

PHP $_SERVER['REQUEST_URI'] doesn't work with hashes [duplicate]

This question already has answers here:
$_SERVER['REQUEST_URI'] with #hash too?
(2 answers)
Closed 6 years ago.
Request Path: http://localhost/1/2/# Example/
print_r($_SERVER['REQUEST_URI']);
Expected: /1/2/# Example/
Actual: /1/2/
Using urldecode doesn't have any effect because PHP is creating the array to begin with. Yes, this isn't an orthodox directory name though is there another way to determine the requested URI in PHP?
The # Parma is not send to the server!

How can I get URL (with some parameters)? [duplicate]

This question already has answers here:
Get URL query string parameters
(11 answers)
Closed 6 years ago.
I have a form on page, with url like this:
site.com/form.index.html?ref=https://login....
And I get page URL via this code:
http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]
But as result I get not full URL, just this:
site.com/form.index.html
How can I get full URL?
You want to add the query string:
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]$_SERVER[QUERY_STRING]";
Additionally, you may replace the http bit with $_SERVER[REQUEST_SCHEME]:
"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]$_SERVER[QUERY_STRING]"

How to get a URL query next to the "#!" prefix? [duplicate]

This question already has answers here:
Get fragment (value after hash '#') from a URL [closed]
(10 answers)
Closed 7 years ago.
I'm trying to get the URL query next the "#!" prefix, for example:
https://mega.co.nz/#!123abc
<?php
$query=$_GET["#!"]; //the example
?>
$query: 123abc.
It is possible to read the query using PHP or .htaccess file? How i can get started?
Thanks for reading and for any help! :)
Try this,
Let your URL:
https://mega.co.nz?query=123abc
Then you can get value as below :
<?php
$query=$_GET["query"]; //the example
?>

What to parameter value from returning url in php [duplicate]

This question already has answers here:
GET URL parameter in PHP
(7 answers)
Closed 7 years ago.
I have a client url[www.mysite.com/page.aspx]
when we put this url in browser then it revert the automatically
with this url
[www.mysite.com/page.aspx?|&CC=121&DD=123&AA=323|&CC=321&DD=555&AA=000]
Now we want to fetch that parameter value in php page through php or jquery.
Kindly Help and give the best suggestions.
You can simply use GET
$cc = $_GET['CC'];
$dd = $_GET['DD'];
You can access those values using $_REQUEST or $_GET

How to pass # in url params? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
# in url getting ignored in php 5.2
I have following link on webpage. Here I am sending return(/profile?id=6#contacts) as url param to return back after operation complete. But it is sending only /profile?id=6 to verify.php script.
http://example.com/verify.php?id=1&sessionId=6&return=/profile.php?id=6#contacts
I know that hash value is not passed to server but I want to know that is there any way to pass compelete return param to server with # value.
Thanks
You need to urlencode() the entire return parameter.

Categories