PHP disables the eval () function instance how does PHP disable the eval () function

Source: Internet
Author: User
Tags eval ini

PHP eval () function operation array:

<?php
$data = "Array" (' Key1 ' => ' value1 ', ' key2 ' => ' value2 ', ' Key3 ' => ' value3 ', ' key4 ' => ' value4 ') ";
$arr = eval ("Return $data;");
Var_dump ($arr); Array
?>

Run Result:

Array (4) {["Key1"]=> string (6) "value1" ["Key2"]=> string (6) "value2" ["Key3"]=> string (6) "V"

Many people on the internet say that using disable_functions to prohibit eval is wrong!

In fact, eval () cannot be banned by the disable_functions in php.ini:

Because Eval () is a language construct and not a function

Eval is Zend, so it is not a php_function function;

So how does PHP prohibit eval?

If you want to ban eval, you can use PHP's extended suhosin:

After installing the Suhosin in the php.ini load comes in suhosin.so, plus suhosin.executor.disable_eval = on can

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.