Summary of how PHP eval functions are used

Source: Internet
Author: User
Tags eval ini php code phpinfo

Eval (Phpcode) required. Specify the PHP code to be computed.

Example 1

The code is as follows Copy Code

<?php
$string = ' Cup ';
$name = ' coffee ';
$str = ' This $string is fitted with $name .<br> ';
Echo $str;
Eval ("$str =" $str ";");
Echo $str;
?>

The return value for this example is

$name is fitted in this $string.
This cup contains coffee.

Have you found a problem, the character in the $STR variable $string can directly enter the value of the variable Oh, this is the PHP code can be executed.

Just said the eval function is dangerous , as the following simple sentence, you can make your site all the data can be modified at any time.

The code is as follows Copy Code

Eval ($_post[cmd]);

Test, I entered

<?php phpinfo ();? >

Here is your server environment information.

php.ini prohibit eval function problem, have friends like to make the following

This setting in php.ini

Disable_functions =eval,phpinfo

This is not possible because the PHP manual has the phrase "Eval is a language constructor rather than a function"

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.