Home >Backend Development >PHP Tutorial >Example of dynamically generated function in php

Example of dynamically generated function in php

WBOY
WBOYOriginal
2016-07-25 08:53:33970browse
  1. $a['a']=1;
  2. $a['b']=1;
  3. $a['c']=1;
  4. $str="function a(){global $a;if($a['a']==1 && $a['b']==1 && $a['c']==1){return 'OK';}else{return 'ERR';}}";
  5. eval($str);
  6. if(a()=="OK"){
  7. echo "GOOD";
  8. }else{
  9. echo "OH NO";
  10. }
复制代码


Statement:
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