I tried to give an string like "A&B" as a parameter to a php file. But because '&' Symbols are used to give multiple params to the file this doesn't work:
http://localhost/Projekte/programm.php?division=A&B
How can I pass this string?
I tried to give an string like "A&B" as a parameter to a php file. But because '&' Symbols are used to give multiple params to the file this doesn't work:
http://localhost/Projekte/programm.php?division=A&B
How can I pass this string?
Use urlencode
function:
$url = 'http://localhost/Projekte/programm.php?division=' . urlencode('A&B');
echo $url;
Output
http://localhost/Projekte/programm.php?division=A%26B
Accessing the GET parameter from programm.php
var_dump($_GET['division']);
Try using the url_encode()
function and url_decode()
functions. These will replace all alphanumeric characters with the appropriate %.. value
http://localhost/Projekte/programm.php?division1=a&division2=b
echo $_GET["division1"];
echo $_GET["division2"];
& is multiple value but it must be name and value so give name1=value&name2=value
or
http://localhost/Projekte/programm.php?division=A&b
$val1 = $_GET["division"];
$val2 = explode("&", $val1);
echo $val2[0].$val[1];