SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    question in ob_start

    hi,

    i have programed a templates system

    first, i make the html page after translated to php code stored in another folder with same name

    if header.html have this code

    HTML Code:
    <if "$user=2">hello</if>
    it will be

    PHP Code:
    <? if ( $user == ) { ?>
    hello
    <?}?>
    template/header.html
    stored as
    template_cache/header.php

    when i want to print template i using this


    PHP Code:
    ob_start();
                include(
    template_cache/header.php);
                
    $this->SHTML ob_get_contents();
                
    ob_end_clean();
                eval(
    "\$this->SHTML = \"$this->SHTML\n\";");

               
                echo 
    $this->SHTML
    $this->SHTML = ob_get_contents();

    will be executed all php code stored in php template file
    and eval will be output variables value

    but in this time
    i make template stored in database

    when i get the content of ( header ) template from database in a variable what i should being to execute it before using eval

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i make some changes in this system

    when i click ( submit ) in control panel it save changes in template to php file
    and i get template from this file to display

    thanks .....

  3. #3
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think its good idea to use eval. I think people in forums has said tons of times the phrase that "most likely if you need to use eval() you are doing something wrong".

  4. #4
    SitePoint Addict
    Join Date
    Jul 2008
    Location
    sudo rm -rf /
    Posts
    386
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you use smarty? smarty.net

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    In this piece of code:-

    PHP Code:
    ob_start();

                include(
    template_cache/header.php);

                
    $this->SHTML ob_get_contents();

                
    ob_end_clean();

                eval(
    "\$this->SHTML = \"$this->SHTML\n\";");

                echo 
    $this->SHTML
    eval is completely unnecessary, you could comment it out and it would work exactly the same.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think its good idea to use eval. I think people in forums has said tons of times the phrase that "most likely if you need to use eval() you are doing something wrong".
    ammmmm
    why !!?

    Quote Originally Posted by buldozerce View Post
    Why don't you use smarty? smarty.net
    i building personal framework to using in all future scripts

    eval is completely unnecessary, you could comment it out and it would work exactly the same.
    my template contain direct variable like $phrase[add_file]
    so eval translate it to its content in language file

    i will try without


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
  •