We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Parse error: syntax error, unexpected T_ELSE in /public_html/system/expressionengine/libraries/Functions.php(680) : eval()‘d code on line 9

Development and Programming

amarbhanu's avatar
amarbhanu
3 posts
12 years ago
amarbhanu's avatar amarbhanu

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

       
jcowen's avatar
jcowen
66 posts
12 years ago
jcowen's avatar jcowen

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.

       
MrBaseball34's avatar
MrBaseball34
99 posts
12 years ago
MrBaseball34's avatar MrBaseball34

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.

       
biblio's avatar
biblio
9 posts
12 years ago
biblio's avatar biblio

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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.