0

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?

Gabriel Weidmann
  • 756
  • 12
  • 16

3 Answers3

3

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']);
Ruslan Osmanov
  • 20,486
  • 7
  • 46
  • 60
1

Try using the url_encode() function and url_decode() functions. These will replace all alphanumeric characters with the appropriate %.. value

mahethekiller
  • 514
  • 3
  • 17
0
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];
paranjothi
  • 103
  • 6