Home > Backend Development > PHP Tutorial > PHP dynamically generated function example_PHP tutorial

PHP dynamically generated function example_PHP tutorial

WBOY
Release: 2016-07-13 10:35:26
Original
794 people have browsed it

The following is an example of a PHP dynamically generated function. The eval function is used in the example. I feel that it is very dangerous if the server allows users to run such a function

Copy code The code is as follows:

$a['a']=1;
$a['b']=1;
$a['c']=1;
$str="function a(){global $a;if($a['a']= =1 && $a['b']==1 && $a['c']==1){return 'OK';}else{return 'ERR';}}";
eval($str );
if(a()=="OK"){
echo "GOOD";
}else{
echo "OH NO";
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/744326.htmlTechArticleThe following is an example of a PHP dynamically generated function. The eval function is used in the example. I feel that if the server allows users to run this The function is very dangerous to copy the code. The code is as follows: ?...
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