#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    4
    Rep Power
    0
    Hi,

    I want to use templates with PHP but I hate the fact of fast template that you have to manually assign each variable.
    Now I have the following function written in perl and this function automaticly converts eacht variable with the corresponding value:

    function Template
    { local(*FILE); # filehandle
    local($file); # file pathlocal($HTML); # HTML data
    $file = $_[0] | | die "Template : No template file specifiedn";
    open(FILE, "<$file") &#0124; &#0124; die "Template : Couldn't open $file : $!n";
    while (<FILE> )
    { $HTML .= $_;
    }
    close(FILE);

    $HTML =~ s/$(w+)/${$1}/g;

    return $HTML;
    }


    Anyone who can translate this in PHP for me?
    It's mostly this line of code: $HTML =~ s/$(w+)/${$1}/g;

    Thanks!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    4
    Rep Power
    0
    No-one?

    [This message has been edited by Mas*Mind (edited March 23, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    4
    Rep Power
    0
    C'mon guys! Don't tell me there are no php-guru's out here who can give me at least a hint
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Helden,Limburg,The Netherlands
    Posts
    33
    Rep Power
    15
    Hi,

    I don't have the time to translate the code for you but s/$(w+)/${$1}/g is a regular expression and you can probably use almost the same code as most regular expression in languages like Javascript and PHP have adopted the Perl-expressions.

    Greetz

    ------------------
    Ramon Litjens
    Boradoli Web Design
    (www.boradoli.nl)
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Location
    Seattle
    Posts
    133
    Rep Power
    16
    You can use the perl regex replace function, this is off the top of my head, you should check the PHP reference for exact syntax:

    $HTML = preg_replace("$(w+)", "${1}", $HTML);

    [This message has been edited by donarb (edited March 29, 2000).]
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Location
    Seattle
    Posts
    133
    Rep Power
    16
    You can use the perl regex replace function, this is off the top of my head, you should check the PHP reference for exact syntax:

    $HTML = preg_replace("$
    (w+)", "${1}", $HTML);

Similar Threads

  1. permissions after uploading
    By Paul Niessen in forum Perl Programming
    Replies: 3
    Last Post: February 15th, 2004, 05:51 PM
  2. explicit specialization problems
    By zheka in forum C Programming
    Replies: 3
    Last Post: October 28th, 2003, 10:09 AM
  3. PHP Fast Template
    By guest in forum Development Articles
    Replies: 41
    Last Post: May 28th, 2003, 09:17 AM
  4. which template system to choose ?
    By irfan_uygur in forum PHP Development
    Replies: 26
    Last Post: October 20th, 2002, 10:29 PM
  5. Fast template form sessions query
    By iain in forum PHP Development
    Replies: 3
    Last Post: May 6th, 2002, 12:05 PM

IMN logo majestic logo threadwatch logo seochat tools logo