PHP eval() Function
Complete PHP Misc Reference
Definition and Usage
The eval() function evaluates a string as PHP code.
The string must be valid PHP code and must end with semicolon.
This function returns NULL unless a return statement is called in the code
string. Then the value passed to return is returned. If there is a parse error
in the code string, eval() returns FALSE.
Syntax
| Parameter |
Description |
| phpcode |
Required. Specifies the PHP code to be evaluated |
Tips and Notes
Note: A return statement will terminate the evaluation of the string immediately.
Tip: This function can be useful for storing PHP code in a database.
Example
<?php
$string = "beautiful";
$time = "winter";
$str = 'This is a $string $time morning!';
echo $str. "<br />";
eval("\$str = \"$str\";");
echo $str;
?>
|
The output of the code above will be:
This is a $string $time morning!
This is a beautiful winter morning!
|
Complete PHP Misc Reference

The Altova MissionKit is an integrated suite of tools ideal for:
- XML development
- Web & Web services development
- Data mapping & integration
- Rendering & publishing XML & database data
- XBRL validation, taxonomy editing, transformation & rendering
The MissionKit for XML Developers includes XMLSpy® - the industry-leading XML editor; MapForce® - a
graphical data mapping, conversion, and integration tool; StyleVision® - a visual XSLT stylesheet designer;
DiffDog® - an XML-aware diff/merge tool; and 2 additional tools.
Try all 6 products free for 30 days!
Download a fully-functional free trial
|
|
|
|