The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
templates, NOT fast template
Discuss templates, NOT fast template in the PHP Development forum on Dev Shed. templates, NOT fast template PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 22nd, 2000, 03:50 AM
|
|
Junior Member
|
|
Join Date: Mar 2000
Posts: 4
Time spent in forums: < 1 sec
Reputation 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") | | 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! URL
|

March 23rd, 2000, 04:03 AM
|
|
Junior Member
|
|
Join Date: Mar 2000
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
No-one? URL
[This message has been edited by Mas*Mind (edited March 23, 2000).]
|

March 26th, 2000, 08:11 AM
|
|
Junior Member
|
|
Join Date: Mar 2000
Posts: 4
Time spent in forums: < 1 sec
Reputation 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
|

March 28th, 2000, 08:47 AM
|
|
Contributing User
|
|
Join Date: Oct 1999
Location: Helden,Limburg,The Netherlands
Posts: 33
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
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)
|

March 29th, 2000, 02:09 AM
|
|
Contributing User
|
|
Join Date: Jun 1999
Location: Seattle
Posts: 133
Time spent in forums: < 1 sec
Reputation Power: 15
|
|
|
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).]
|

March 29th, 2000, 02:12 AM
|
|
Contributing User
|
|
Join Date: Jun 1999
Location: Seattle
Posts: 133
Time spent in forums: < 1 sec
Reputation Power: 15
|
|
|
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);
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|