<?php
$xs = eval("if ('1' == '0')
echo 'never';
else
echo 'always';");
//echo $xs;
This code returns 'always' but i don't want it. I need to take this variable elsewhere.
Sorry for bad english.
EDIT:
PEOPLE!!!!!!!This sample code. I know that eval() in this case is not needed, but the code in my other projects will be. I need to what eval() returns were entered into a variable. "
Here's a simple way to get the result:
<?php
ob_start();
eval("if ('1' == '0')
echo 'never';
else
echo 'always';");
$xs = ob_get_contents();
ob_end_clean();
//echo $xs;
To get the return value of eval()
you'll need to return something inside the evaluated code, e.g.:
$xs = eval("return '1' == '0' ? 'never' : 'always';");
echo $xs; // echoes 'always'
$xs = ('1' == '0') ? 'never' : 'always';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With