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

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!

Related

How to extract path url using PHP [duplicate]

This question already has answers here:
PHP Parse URL From Current URL
(6 answers)
Closed 3 years ago.
How can I extract path in url using php ?
example :
text input = https://drive.google.com/open?id=1OJOZBBUCa5SsmUF3UdGJCk7A4t2kAHVr
output = 1OJOZBBUCa5SsmUF3UdGJCk7A4t2kAHVr
You can use $_GET['id'].
Or $_SERVER['QUERY_STRING'] to get all the parameters.

replace particular value from url [duplicate]

This question already has answers here:
PHP, Delete parts of a URL variable [duplicate]
(3 answers)
Closed 4 years ago.
I want to replace '/50' with URL.my URL is
http://localhost/CI/admin/pcustomer/cprofile/50?customer=18267&mobile=&nearby=
I want url as
http://localhost/CI/admin/pcustomer/cprofile?customer=18267&mobile=&nearby=
From that little info in your question, this seems to be the simplest way to achieve "I want to replace '/50' with URL"
$url = str_replace('/50', '', 'http://localhost/CI/admin/pcustomer/cprofile/50?customer=18267&mobile=&nearby=');

PHP 7.0 - urlencode/urldecode not symetrical [duplicate]

This question already has answers here:
What is the equivalent of JavaScript's encodeURIcomponent in PHP?
(5 answers)
urlencode vs rawurlencode?
(11 answers)
Closed 4 years ago.
I save a web page edited by users in our app backend
in js : encodeURIComponent returns this
%3C!--%20saved%20from%20url%3D(0077)https%3A%2F%2Fwww.w3schools.com%2Fw3css%2Ftryw3css_templates_gourmet_catering.htm%23about
in php : urldecode returns this
<!-- saved from url=(0077)https:\/\/www.w3schools.com\/w3css\/tryw3css_templates_gourmet_catering.htm#about
so far so good....
now, when I fetch the data from the db and reencode it in php urlencode returns this :
%3C%21--+saved+from+url%3D%280077%29https%3A%2F%2Fwww.w3schools.com%2Fw3css%2Ftryw3css_templates_gourmet_catering.htm%23about
so it ends up in JS beeing decoded with + all over the place :
<!--+saved+from+url=(0077)https://www.w3schools.com/w3css/tryw3css_templates_gourmet_catering.htm#about
1 - yes I could just replace the + but I feel I am doing something wrong
2 - why does encodeurl do that if it is not compatible with js decodeURIcomponent ?
regards

How can get the current path in PHP [duplicate]

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

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