php - 如何从php上的GET变量回显javascript编码的url
问题描述
如何从 php 上的 GET 方法回显解码的 url,
我有这个链接:
localhost/whatsapp?text=Hello%2C%20Who%20are%20U%3F%0AName%3A%20%0AAddress%3A%20%0AAge%3A%20
使用此代码
$text = $_GET['text'];
header("Location: https://web.whatsapp.com/send?phone=00000000&text=".$text);
但得到错误
警告:标头可能不包含多个标头,在 index.php 中检测到新行在线
解决方案
当您从中检索值时$_GET
,它们会被URL 解码。如果你想把它传回去,你需要再次编码,这样换行符、空格和其他奇怪的字符就会被编码。用于urlencode($text)
此。
$text = $_GET['text'];
header("Location: https://web.whatsapp.com/send?phone=00000000&text=".urlencode($text));
推荐阅读
- json - 如果使用推送填充输出,则 Thingworx 输出 JSON 错误
- c# - 无法使用来自服务器的 openssl 库处理服务器名称指示
- python - 我如何重塑这个 numpy 数组?
- angular7 - 如何在 http 获取请求和响应中使用离子加载?
- java - 是否可以使用同一个按钮的意图调用两个活动?
- nginx - 音频在 openmeeting 4.0.4 中不起作用,单击开始录制测试时它会被禁用
- flutter - 如何在 Flutter 中进行“收据验证”?
- javascript - Angular 的 nativeElement 的 offsetWidth 为 0
- python - Gensim 导入错误“ImportError:DLL 加载失败:%1 不是有效的 Win32 应用程序。”
- objective-c - ios 13 - 带有 UISearchBar _searchField 的自定义 SearchBar 不起作用