PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 22nd, 2000, 03:50 AM
Mas*Mind Mas*Mind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 4 Mas*Mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Mas*Mind
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

Reply With Quote
  #2  
Old March 23rd, 2000, 04:03 AM
Mas*Mind Mas*Mind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 4 Mas*Mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Mas*Mind
No-one? URL

[This message has been edited by Mas*Mind (edited March 23, 2000).]

Reply With Quote
  #3  
Old March 26th, 2000, 08:11 AM
Mas*Mind Mas*Mind is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 4 Mas*Mind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Mas*Mind
C'mon guys! Don't tell me there are no php-guru's out here who can give me at least a hint

Reply With Quote
  #4  
Old March 28th, 2000, 08:47 AM
Ramon Ramon is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Helden,Limburg,The Netherlands
Posts: 33 Ramon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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)

Reply With Quote
  #5  
Old March 29th, 2000, 02:09 AM
donarb donarb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 1999
Location: Seattle
Posts: 133 donarb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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).]

Reply With Quote
  #6  
Old March 29th, 2000, 02:12 AM
donarb donarb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 1999
Location: Seattle
Posts: 133 donarb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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);

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > templates, NOT fast template

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap