PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 3rd, 2004, 11:46 PM
velocityX velocityX is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 72 velocityX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 6
Send a message via AIM to velocityX
replacing text to do php includes

does anyone know a code if i put "[:body:]" inside somewhere of my design it will be replaced and it will include a php file?

Reply With Quote
  #2  
Old January 4th, 2004, 01:21 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
perhaps regular expressions would help out a bit?

http://www.php.net/manual/en/ref.regex.php

Reply With Quote
  #3  
Old January 4th, 2004, 04:20 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Slurp the contents of the include and the design template into variables and then do a regex such as preg_replace("/\[:body:\]/",$include_txt,$template) and print the results.

Reply With Quote
  #4  
Old January 4th, 2004, 04:57 PM
velocityX velocityX is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 72 velocityX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 6
Send a message via AIM to velocityX
Quote:
Originally posted by dhouston
Slurp the contents of the include and the design template into variables and then do a regex such as preg_replace("/\[:body:\]/",$include_txt,$template) and print the results.


for the $include_txt i cant replace it with "include('pages.php');" ?

Reply With Quote
  #5  
Old January 4th, 2004, 06:40 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
that's something I didn't consider when i mentioned regular expressions... (oops)

velocityX, you can't do it that way since include() doesn't return the information, it simply displays it... I can't really think of a way to clarify this at all...

If its only HTML you're reading from the include file, then you could simply use fread...

here's a sample from the php documenation:
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);

Reply With Quote
  #6  
Old January 4th, 2004, 09:31 PM
velocityX velocityX is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 72 velocityX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 36 sec
Reputation Power: 6
Send a message via AIM to velocityX
so there's no way I can replace [:body:] with any includes?

Reply With Quote
  #7  
Old January 5th, 2004, 07:15 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Well, the solution MadCow and I have proposed effectively replaces [:body:] with an include -- it's just a roundabout way of doing it.

Reply With Quote
  #8  
Old January 5th, 2004, 06:34 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
The way posted above is the only possible way to do this, if you are using it on a url and need the code, let me know ...

Well, I guess he velocity is trying to include a text file because a php file wont be required to be included in a particular place for its variables to be available.

So MadCow's way is efficient.
__________________
ExoHelpDesk
ExoCrew Free Services

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > replacing text to do php includes


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT