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
?>
Related
This question already has answers here:
Getting parts of a URL (Regex)
(30 answers)
Closed 3 years ago.
I have a URL like so:
http://example.com/var1/var2
What I'd like to is get VAR 1 from the querystring. I've tried using a regex but I'm not really very familiar with them. Is there an easier way?
Another approach
<?php
$e = explode("/",parse_url("http://example.com/a/b")["path"])[1];
// $e now is "a"
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]"
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
This question already has answers here:
What is the difference between POST and GET? [duplicate]
(7 answers)
Closed 7 years ago.
I have no time and too tired to struggle with this, so I decided to ask here: I've created the file my.php which contains only:
<?php var_dump( $_POST ); ?>
And then I open the file using browser like this:
www.domain.com/my.php?post1=hey&post2=ho&post3=letsgo
And in the browser I have array(0) { } as a response.
Question: What could I possibly done wrong??
Thanks!
In URL are GET parameters, not POST.
echo $_GET['post1']; // hey
echo $_GET['post2']; // ho
echo $_GET['post3']; // letsgo
You cant pass POST variables through URL.
u r using GET method..
This question already has answers here:
How do I extract query parameters from a URL string in PHP?
(3 answers)
Closed 8 years ago.
This would be an example:
redirect
dynamic_word can be changed because it is dynamic. When click "redirect", dynamic_word will be extracted. So, how to extract it in redirect.php file ? Thanks !
Use $_GET to get parameters from an URL
<?php
$thatName = $_GET['q'];
echo $thatName;
Result
dynamic_word
If samitha's correct looking answer is incorrect then perhaps you mean you would like to extract the dynamic word from a string.
In that case you could do
<?php
$string = 'http://mywebsite.com/redirect.php&q=dynamic_word';
$ex_stirng = explode('&q=', $string);
$dynamic_word = $ex_string(1);
?>
Or even use the strstr function:
http://www.php.net/manual/en/function.strstr.php