Please suggest me why display this types of error, default php function is eval(); here i am using to expression engine v2.5.2 and my php server v 5.2.17.
Parse error: syntax error, unexpected T_ELSE in /public_html/system/expressionengine/libraries/Functions.php(680) : eval()‘d code on line 9
function evaluate($str)
{
return eval('?'.'>'.$str.'<?php ');
}Here error show this path return eval(’?’.’>’.$str.’<?php ‘);
please suggest me site is working show parse error how to remove it, please suggest me.., first time using expression engine
i did modified function like to return eval(’ ?>’.$str.’<?php ‘); or return eval(” ?>”.$str.”<?php “); but not working, Please suggest me.. what is wrong
Typically it isn’t a problem with that actual file - it’s a core file, so there shouldn’t be.
You either must be using the EE tags incorrectly in your template, or you have a problem with the php you are using in a template.
There’s typically only one way to solve this when you are seriously stuck, and that’s to remove everything from your template and gradually re-add it to your template, a line at a time until you work out which is the offending tag.
I modified my Functions.php so I can figure out where things were going wrong. All you have to do is set $debug = true and you’ll get a file with the actual code that is being parsed written.
/**
* eval()
*
* Evaluates a string as PHP
*
* @access public
* @param string
* @return mixed
*/
function evaluate($str)
{
$debug = false;
// return eval('?'.'>'.$str.'<?php ');
$x = eval('?'.'>'.$str.'<?php ');
if($x === false) {
if($debug) {
$timestamp = date("m-d-Y H:i:s");
$msg = "Timestamp:".$timestamp."\n".$str;
$fp = fopen("/var/tmp/Functions_Exception.txt", 'a');
fwrite($fp, $msg . "\n");
fclose($fp);
}
} else {
return $x;
}
}(BTW, this was in version 1.4.0, it may have changed in later versions but it looks the same in 2.5.2) I really wished they had a way to get the actual template name that is being evaluated.
Thanks, that didn’t work for me. If your code is coming back as a fatal error, you’ll never get the debug code. Here’s the quick workaround I used (then removed):
/**
* eval()
*
* Evaluates a string as PHP
*
* @access public
* @param string
* @return mixed
*/
function evaluate($str)
{
if (empty($GLOBALS['evalcount'])){ $GLOBALS['evalcount'] = 1; }
else {
$GLOBALS['evalcount']++;
}
echo "<HR>";
echo "<H1>". $GLOBALS['evalcount'] ."</h1>";
echo "<textarea rows=30 cols=200>";
echo $str;
echo "</textarea>";
flush();
ob_flush();
return eval('?'.'>'.$str.'<?php ');
}That’ll print (in a text area) each chunk of html/php that gets streamed through evaluate(), and flush the buffer before eval()’ing so you can see it. Take the last <textarea> and run it as a php file to see line numbers and and fix the problem. Then, of course, revert your function evaluate() to the original!
M.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.