ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Functions.php(680) : eval()'d code on line 3 errors

August 30, 2012 8:02am

Subscribe [2]
  • #1 / Aug 30, 2012 8:02am

    omega22

    2 posts

    Hello,

    I am working on a current install of 2.5.2.

    I seem to be getting system errors from the most basic php enabled templates. I’ve switched them between input / output php parsing to see if it would make a difference.

    Error Example:

    Parse error: syntax error, unexpected ‘%’ in /home/dir1/public_html/system/expressionengine/libraries/Functions.php(680) : eval()‘d code on line 3

    Code example:

    <?php
    $dob = new DateTime('{current_date format='%d %F %Y'}');
    $now = new DateTime('{registration-first-day format='%d %F %Y'}');
    
    // This returns a DateInterval object.
    $age = $now->diff($dob);
    
    // You output the date 
    echo 'This person is ' .$age->format('%y') .' years old.';
    ?>

    Tried embedding too:

    $dob = new DateTime('{embed:the_current}');
    $now = new DateTime('{embed:the_start}');

    Is there something wrong with my install?

     

  • #2 / Aug 31, 2012 2:46pm

    Shane Eckert

    7174 posts

    Hey Omega22,

    You will want to select output parsing. Because you want to use those variables in PHP.

    In PHP double quotes and single quites do different things.

    The single quotes are literal.

    Change all the single quotes into double quotes aside from the date formats.

    That should get you back in business.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases