Home > Backend Development > PHP Tutorial > 字符串中变量轮换的方法

字符串中变量轮换的方法

WBOY
Release: 2016-06-13 11:57:41
Original
1165 people have browsed it

字符串中变量替换的方法
我想做在字符串中替换变量,比如:
$a = "12345";
echo "a=$a"; 就会打印出 a = 12345;
这个是我想要的结果。但是现在有个问题,就是我把a=$a这个字符串存在数据库里后再取出来,同样的语句打印出来的就是
a=$a,我想问一下,如果我仍然想实现上边的效果应该怎么做?
------解决方案--------------------
用Eval来实现。
------解决方案--------------------
$str = 12345;
eval("\$s = \"a=$str\";");
echo $s;

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