Home > php教程 > php手册 > body text

php动态生成函数示例

PHPz
Release: 2018-09-30 16:59:59
forward
1262 people have browsed it

这篇文章主要介绍了php动态生成函数示例,需要的朋友可以参考下

以下就是php动态生成函数示例,示例中用到了eval函数,我感觉如果服务器上允许用户运行这样的函数是非常危险的

代码如下:

<?
$a[&#39;a&#39;]=1;
$a[&#39;b&#39;]=1;
$a[&#39;c&#39;]=1;
$str="function a(){global \$a;if(\$a[&#39;a&#39;]==1 && \$a[&#39;b&#39;]==1 && \$a[&#39;c&#39;]==1){return &#39;OK&#39;;}else{return &#39;ERR&#39;;}}";
eval($str);
if(a()=="OK"){
 echo "GOOD";
}else{
 echo "OH NO";
}
Copy after login

更多相关教程请访问 php编程从入门到精通全套视频教程

 

Related labels:
source:jb51.net
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!