Php 如何通过$\u get获取参数

Php 如何通过$\u get获取参数,php,html,utf-8,Php,Html,Utf 8,我无法获取参数$\u get,它的值包含字符:'#' 我有以下代码: <iframe src="http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=<span style="color: #ff0000;">Empty content.</span>"> 当我更改或删除字符时:“#”一切正常。例如: <iframe sr

我无法获取参数
$\u get
,它的值包含字符:'#'

我有以下代码:

<iframe src="http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=<span style="color: #ff0000;">Empty content.</span>">

当我更改或删除字符时:“#”一切正常。例如:

<iframe src="http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=<span style="color: ff0000;">Empty content.</span>">

如何完成参数(文本内容)值

注意:我正在PHP中测试获取此参数/值
$\u获取['text\u content']

谢谢

您需要使用函数,因为
之后的任何内容都不会被视为URL的一部分(浏览器不会将该部分发送到服务器)。

您需要使用函数,因为
之后的任何内容都不会被视为URL的一部分(浏览器不会将该部分发送到服务器)

字符串中的引号也会引起问题。为您的顶级iframe尝试以下内容:

<iframe src="http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=%3Cspan%20style%3D%22color%3A%20%23ff0000%3B%22%3EEmpty%20content.%3C%2Fspan%3E">

您需要对通过GET请求传入的任何字符串进行urlencode(),并在从$\u GET获取字符串后对其进行URDECODE()

字符串中的引号也会引起问题。为您的顶级iframe尝试以下内容:

<iframe src="http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=%3Cspan%20style%3D%22color%3A%20%23ff0000%3B%22%3EEmpty%20content.%3C%2Fspan%3E">

在将其发送到php脚本进行处理之前,您应该真正使用urlencode,然后使用urldecode正常输出它

也许可以试试:

<iframe src="<?php urlencode('http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=<span style="color: #ff0000;">Empty content.</span>'); ?>">

在将其发送到php脚本进行处理之前,您应该真正使用urlencode,然后使用URLEDECODE正常输出它

也许可以试试:

<iframe src="<?php urlencode('http://localhost/wp352/wp-content/plugins/heloworld/templates/options-rte.php?text_content=<span style="color: #ff0000;">Empty content.</span>'); ?>">

尝试使用
url\u encode
对url进行编码尝试使用
url\u encode
对url进行编码您也不需要对所有内容进行url编码,只需对传递到脚本中的参数进行url编码。请注意,您应该
urlencode
仅对传递的值进行编码,而不是对整个链接进行编码
urlencode
/
编码为
%2F
,这将导致链接断开。您也不需要对所有内容进行urlencode编码,只需对传递到脚本中的参数进行urlencode。请注意,您应该
urlencode
仅对传递的值进行编码,而不是对整个链接进行编码
urlencode
/
编码为
%2F
,这将导致断开链接。