Php - Executing statments as a string using eval function, Eval a statement as string

Executing statments as a string using eval function

A statement stored in a string can be executed using the eval function.

Most of the programming language has build-in eval function which is used to evaluate a math operations

PHP Code
<?php
$str = "\$math=15*log(10);";
eval($str);
echo $math;
?>
Output: 34.5387763949

The above php code will evaluate the math query or statement which is stored in a variable($str) as a string.

The topic on Php - Executing statments as a string using eval function is posted by - Math

Hope you have enjoyed, Php - Executing statments as a string using eval functionThanks for your time

Tech Bluff