|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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?
|
|
#2
|
||||
|
||||
|
|
|
#3
|
||||
|
||||
|
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.
|
|
#4
|
|||
|
|||
|
Quote:
for the $include_txt i cant replace it with "include('pages.php');" ? |
|
#5
|
||||
|
||||
|
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); |
|
#6
|
|||
|
|||
so there's no way I can replace [:body:] with any includes? |
|
#7
|
||||
|
||||
|
Well, the solution MadCow and I have proposed effectively replaces [:body:] with an include -- it's just a roundabout way of doing it.
|
|
#8
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > replacing text to do php includes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|