HOW TO CALL link in php html javascript
HOW TO CALL link in php html javascript
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
example Array ( [0] => dir1/pag.php [1] => OlaMundo )
Finally you are the second element of array $partes{1}
In 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"