HOW TO CALL https://www.domin.com/?textonome [closed]

-2

HOW TO CALL link in php html javascript

    
asked by anonymous 16.12.2017 / 19:12

2 answers

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 an array of strings, each as a string substring formed by splitting it from? (question mark).

example Array ( [0] => dir1/pag.php [1] => OlaMundo )

Finally you are the second element of array $partes{1}

    
16.12.2017 / 20:50
0

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"
    
17.12.2017 / 03:53