Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,494 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,708 people online right now. Registration is fast and FREE... Join Now!




STR_Repace

 
Reply to this topicStart new topic

STR_Repace

duffsstuff
24 Feb, 2008 - 03:10 PM
Post #1

D.I.C Head
**

Joined: 10 Sep, 2006
Posts: 67


My Contributions
I want to have a html file and be able to but dynamic information into it.

Is it possible to use str_replace to do this?

In the HTML file:
CODE

<html>
   <body>
      {gadget:blog}
   </body>
</html>


In the PHP file:
CODE

<?php
   Class Class{
      function load($name){
         require_once $name.'.php';
      }
   }

   $page = file_get_contents(layout.html);
   $page = str_replace('{gadget:'.$name.'}', $class->load($name), $page);
   print $page;
?>

User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: STR_Repace
24 Feb, 2008 - 05:42 PM
Post #2

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

is posable, code looks good.
have you tryed this you posted?

User is offlineProfile CardPM
+Quote Post

duffsstuff
RE: STR_Repace
24 Feb, 2008 - 05:46 PM
Post #3

D.I.C Head
**

Joined: 10 Sep, 2006
Posts: 67


My Contributions
i tryed and failed.. sad.gif I instead added php to the html file for the get argument.
User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: STR_Repace
24 Feb, 2008 - 05:56 PM
Post #4

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

that is what i usually do anyway.

i think is the braket placmet is causeing the problem.
have had many issues using things php uses.
creat it as a $string = '}'; usually works.

but thier is a template class in php snipits may give you some clues.
http://www.dreamincode.net/code/snippet863.htm

This post has been edited by SpaceMan: 24 Feb, 2008 - 05:59 PM
User is offlineProfile CardPM
+Quote Post

duffsstuff
RE: STR_Repace
24 Feb, 2008 - 05:59 PM
Post #5

D.I.C Head
**

Joined: 10 Sep, 2006
Posts: 67


My Contributions
well I think I have it working right now, don't mess with something that is working. biggrin.gif
User is offlineProfile CardPM
+Quote Post

SpaceMan
RE: STR_Repace
24 Feb, 2008 - 06:04 PM
Post #6

D.I.C Regular
Group Icon

Joined: 20 Feb, 2003
Posts: 270

agree, lol
User is offlineProfile CardPM
+Quote Post

k0b13r
RE: STR_Repace
25 Feb, 2008 - 01:01 PM
Post #7

D.I.C Head
Group Icon

Joined: 18 Jul, 2006
Posts: 196



Thanked: 1 times
Dream Kudos: 250
My Contributions
You can use one of many template engines, for example Smarty or PHP-TAL ... but I prefer Smarty ^^

This post has been edited by k0b13r: 25 Feb, 2008 - 01:02 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 07:58PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month