English 中文(简体)
通行证和盘问
原标题:Passing & in query string
  • 时间:2012-04-19 06:24:10
  •  标签:
  • php

I want to pass & operator in query string. I tried to use urlencode and urldecode but its not working. I am doing this:

$abc="A & B";
$abc2=urlencode($abc);

然后,我顺从这样的价值。

<a href="hello.php?say=<?php echo $abc2 ?>"><?php echo $abc;?></a>

页: 1

$abc=$_GET[ say ];
$abcd=urldecode($abc );
echo $abcd;

但产出不是<代码>。 A & B

我做了什么错误?

最佳回答

基本上,我应在我的网络服务器上努力工作:

$a =  A & B ;
echo urlencode($a);
echo  <br /> ;
echo urldecode(urlencode($a));

产出

A+%26+B
A & B

我猜测你在逻辑上或玩物上有另一个错误,造成你和你的办公室;在你的法典中,不要正确地编码,在你的血缘物编码中打着子。

你们的所有法典或你们是否都使用“传真”? 那么,你的原法典将是有益的。

问题回答

引证:

$url =  ?  . http_build_query(array(
   say  =>  A & B 
));

// Then just:
echo $_GET[ say ];

Live example:

看来,你在以下法典第2行中添加了一条插图:

$abc = $_GET[ say ];
$abcd = urldecode($abc);
echo $abcd;

并且,是一种特殊的超文本,你需要将其改为<代码>&amp;。

引证:

$abc = "A & B";
<a href="hello.php?say=<?php echo htmlentities($abc); ?>"><?php echo $abc; ?></a>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签