【发布时间】:2017-04-20 05:28:53
【问题描述】:
代码:
<?php
include('conn.php');
$student_id = $_SESSION['student_id'];
$college_name = $_GET['college_name'];
$college_name22 = explode('(', $college_name);
if(preg_match('#\((.*?)\)#', $college_name, $match))
{
$match[1] = lcfirst($match[1]);
}
else
{
$match[1] = 'All';
}
?>
如果 url 有类似
的字符串cstest/view.php?college_name=Agra%20Public%20Institute%20of%20Technology%20&%20Computer%20Education,%20Artoni%20(Pharmacy)
我想分解以下字符串,即
Agra%20Public%20Institute%20of%20Technology%20&%20Computer%20Education,%20Artoni%20(Pharmacy)
当我回显 $college_name 时,它只显示 (Agra Public Institute of Technology) 而不是全名,即 (Agra Public Institute of Technology & Computer Education, Artoni) 和 $match[1] 包含 (pharmacy),当我没有显示打印 $match[1] 它显示“全部”。那么,我该如何解决这个问题呢?
谢谢
【问题讨论】:
-
var_dump($_GET)看起来像什么?对于初学者,它不会包含 URL 编码的字符串。如果您访问的 URL 中包含,和(,则您的浏览器有问题,它们也会被编码为 %2C 和 %28。
标签: php