我正在从用户获取输入并对该输入文本执行过滤。
CODE问题是,当我静态地采取$s
时,它工作得很好,但是当我以这种方式传递它:
http:/mylocalpi/phone_filter.php?text=%27my%20long%20STRING%20with%20124%20mynumberis%208989243three56%20some%2040one34two3473%27
和
$s = $_GET['text']; //
// $s = "my long STRING with 124 mynumberis 4054545456 8989243three56 some Numbers 402three1345233nine3 5023one34533"; this works fine
则不过滤最后一个单词。有人能告诉我这里有什么问题吗?
使用
$s = urldecode($_GET['text']);
据我所知,您在常量中使用的字符串与您通过URL发送的字符串之间缺乏相似性:
<<p> 常数/strong>:$s = "my long STRING with 124 mynumberis 4054545456 8989243three56 some Numbers 402three1345233nine3 5023one34533";
$s = "'my long STRING with 124 mynumberis 4054545456 8989243three56 some Numbers 402three1345233nine3 5023one34533'";
因为你的URL看起来像这样:
?text=%27…%27
与
相同?text='…'
你可以看到你发送了一对额外的'
(%27
)包围你的字符串,你不需要他们。试着看看如果字符串的静态版本以那些'
开始和结束会发生什么。你的URL应该是这样的:
?text=my%20long%20STRING%20with%20124%20mynumberis%204054545456%208989243three56%20some%20Numbers%20402three1345233nine3%205023one34533
没有任何开头或结尾的'
(%27
)。
要么这样,要么尝试修复过滤器以在处理字符串时忽略'
。