SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    eval(); not liking <?php

    I'm trying to make a template system that has php codes in it so I have the template replace all <!-- PHP --> and <!-- /PHP --> with <?php and ?> then I eval(); the whole thing... doesn't work. I keep gettin this error.

    HTML Code:
    Parse error: parse error, unexpected '<' in /home/zero/public_html/dstats/includes/style.php(45) : eval()'d code on line 1
    Anyone know if eval doesn't like the <?php ?> tags or why its not working when I str_replace the <!-- PHP -->'s?

  2. #2
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why don't you just include the php files?

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because its part of a template system in which the whole template becomes a string. So I need to eval it so I cna use the include.

  4. #4
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If eval() is the answer, you're almost certainly asking the wrong question.
    .

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when you call eval, the php parser does not drop out of php mode first. you do not need opening/closing php tags. if you _want_ to drop out of php mode, then you may

    PHP Code:
    // good
    $code = 'echo $foo;';
    eval($code);

    // bad
    $code = '<?php echo $foo?>';
    eval($code);


    // good
    $code = '?> <html> <?php';
    eval($code);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •