Home > Backend Development > PHP Tutorial > 怎么输出URL里传来的变量$id如 tool.php?info=200@qq@帐号$id

怎么输出URL里传来的变量$id如 tool.php?info=200@qq@帐号$id

WBOY
Release: 2016-06-13 13:51:22
Original
984 people have browsed it

如何输出URL里传来的变量$id如 tool.php?info=200@qq@帐号$id
$id=$_SESSION['id'];
$info=$_GET['info'];
$arr=expolde("@",$info);

可能有朋友会问直接将$id直接输出$id的值;

因为$id是管理写进的然后用户点击这个连接tool.php?info=@qq@帐号$id
然后就会自动输出用户的ID了。

我想过用eval这个函数但是又有朋友说这个不安全。想请问下还有没有其它办法将数组$arr[2]里的$id输出成变量$id呢??



------解决方案--------------------
假定最终的数据还是取自 $_SESSION,则
$v = preg_replace('/\$(\w+)/ie', '$_SEEION["$1"]', $v);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template