php eval() 函数操作数组:
1
2
3
4
5
|
<?php $data = "array('key1'=>'value1','key2'=>'value2','key3'=>'value3','key4'=>'value4')" ; $arr = eval ( "return $data;" ); var_dump( $arr ); //array ?> |
运行结果:
1
|
array (4) { [ "key1" ]=> string(6) "value1" [ "key2" ]=> string(6) "value2" [ "key3" ]=> string(6) "value3" [ "key4" ]=> string(6) "value4" } |
网上很多说使用disable_functions禁止掉eval的方法都是错误的!
其实eval()是无法用php.ini中的disable_functions禁止掉的 :
because eval() is a language construct and not a function
eval是zend的,因此不是PHP_FUNCTION 函数;
那么php怎么禁止eval呢?
如果想禁掉eval可以用php的扩展 Suhosin:
安装Suhosin后在php.ini中load进来Suhosin.so,再加上suhosin.executor.disable_eval = on即可
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!