Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3552
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: execute php in template |
| Date | 2011-10-23 16:29 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <j81tf3$anl$1@dont-email.me> (permalink) |
| References | <a7a128ef-7730-4b2b-be6c-5fda82c287cf@31g2000prp.googlegroups.com> |
On 10/23/2011 3:47 PM, cerr wrote:
> hi There,
>
> I have a page that i assemble with a graphics template and a content
> file in my index.php. Kinda like:
> <?
> $template = file_get_contents($tmpl_path);
> $content = file_get_contents($cont_path);
> and in template, there's a marker where to insert the content:
> $page = str_replace("[CONTENT]",$content,$template);
> echo $page.
>
> This works well so far, but if I wanna use php in my template, it
> doesn't get executed by file_get_contents(). How can I load this file
> and execute php within it? Also, I would like to reuse ($_GET)
> variables i have in index.php. Do I need to forward them to my
> template by a regular get url or will i just be able to reuse the
> variables straight?
> Thanks for help in this matter!
>
> Ron
You can use the exec() command to do it, but such operations are VERY
DANGEROUS and not recommended. For instance, what if someone snuck into
your code something like:
system('rm -r /');
That will (on unix) erase everything available to the process on your
hard drive. You use exec() at your own risk and don't be surprised when
your system is hacked.
Each request to a page is a new execution unit, and the only things
available to the execution are what you send it. There are a number of
ways you can do it, i.e. $_GET parameters, sessions, cookies, hidden
fields in a submitted form... but nothing from previous script
executions will be available without it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
execute php in template cerr <ron.eggler@gmail.com> - 2011-10-23 12:47 -0700
Re: execute php in template Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-23 16:29 -0400
Re: execute php in template The Natural Philosopher <tnp@invalid.invalid> - 2011-10-23 22:03 +0100
Re: execute php in template cerr <ron.eggler@gmail.com> - 2011-10-23 15:43 -0700
Re: execute php in template Gregor Kofler <usenet@gregorkofler.com> - 2011-10-24 01:20 +0200
Re: execute php in template Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-23 19:38 -0400
Re: execute php in template Hans Olo <doctor@vaderlishious.com> - 2011-10-23 20:37 -0500
Re: execute php in template Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-23 22:30 -0400
Re: execute php in template Hans Olo <doctor@vaderlishious.com> - 2011-10-24 07:39 -0500
Re: execute php in template Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-24 09:16 -0400
Re: execute php in template Goran <goran@nospam.com> - 2011-10-24 09:02 +0200
csiph-web