PHP eval() Function
Example
Evaluate a string as PHP code:
The output of the above code is:
This is a $string $time morning!
This is a beautiful winter morning!
Definition and Usage
The eval() function evaluates a string as PHP code.
The string must be valid PHP code and must end with a semicolon.
**Note:** A return statement immediately terminates evaluation of the string.
**Tip:** This function is useful for storing code in database text fields for later evaluation.
Syntax
eval(
phpcode
)
| Parameters | Description |
|---|---|
| phpcode | Required. Specifies the PHP code to evaluate. |
Technical Details
| Return Value: | Returns the value passed to return if a return statement is called in the code string, otherwise NULL. If there is a parse error in the code string, eval() returns FALSE. |
|---|---|
| PHP Version: | 4+ |
PHP Misc Reference Manual