-3
HOW TO CALL THE https://www.domin.com/? Olamundo in php html javascript
-3
HOW TO CALL THE https://www.domin.com/? Olamundo in php html javascript
0
PHP
$uri = $_SERVER['REQUEST_URI'];
$partes = explode("?",$uri); //Divide uma string em strings
echo $partes{1};
$_SERVER['REQUEST_URI'] - The URI provided to access the current page
Examples
1: https://www.dominio.com/?OlaMundo
will return /?OlaMundo
2: https://www.dominio.com/dir1/pag.php?OlaMundo
returns dir1/pag.php?OlaMundo
explode() returns a string array, each as string substring formed by dividing it from ? (question mark).
example Array ( [0] => dir1/pag.php [1] => OlaMundo )
finally you the second element of the array $partes{1}
0
Javascript:
location.href.split('?').pop();
Example (where url_
would be the page URL):
url_ = "http://www.dominio.com/livro.html?olamundo";
alert(url_.split('?').pop()); // exibe "olamundo"
Or using lastIndexOf
:
url_ = location.href;
url_.substring(url_.lastIndexOf("?")+1, url_.length);
Example (where url_
would be the page URL):
url_ = "http://www.dominio.com/livro.html?olamundo";
alert(url_.substring(url_.lastIndexOf("?")+1, url_.length)); // exibe "olamundo"
Browser other questions tagged php javascript html
You are not signed in. Login or sign up in order to post.
Improve your question. I can not understand the doubt.
– Valdeir Psr
Welcome Davidson BPE, important posts for you to read https://pt.meta.stackoverflow.com/questions/5483/manual-de-como-n%C3%83o-fazer-perguntas/5485#5485 and read this also https://pt.meta.stackoverflow.com/questions/como-por-que-aceitar-uma-resposta/1079#1079
– user60252