You are here: [PHP] Generating a php file « PHP « IT news, forums, messages
[PHP] Generating a php file

Posted by Rory Browne on 05/12/05 01:02

Sorry forgot to cc to the list - again

I'm still not sure I understand, although I'm getting there.

This might be useful.
$dynamicly_generated_script = "<?php
\$buffer = \$_SERVER['QUERY_STRING'];
\$somevar = '{$this->somevalue}';
?>";

As might this:
$dyn_gen_script = sprintf(
'<?php
$buffer = $_SERVER["QUERY_STRING"];
$somevar = \'%s\';
?>'
, $this->somevar );


On 5/11/05, Dan Rossi <php@electroteque.org> wrote:
>
> On 12/05/2005, at 6:03 AM, Rory Browne wrote:
>
> > You can start by clarifying. I had to read your message three times
> > before I got a vague understanding.
> >
> > What I'm hearing is that you want to put something like
> > <?php $msg = get_message(); ?> into a string? You are having
> > difficulty doing this because you are finding that your string
> > contains the value of $msg, instead of a doller sign, followed by
> > 'msg'?
> >
> > If so, then you can:
> >
> > Use Single Quotes:
> > $code = '<?php $msg = get_message(); ?>'
> >
> > or Escape your $-signs, by placing a backslash(\) in front of the
> > $-sign
> > $code = "<?php \$msg = get_message(); ?>";
> >
> >
>
> I've had a habit of this of late ! Let me clarify for you then ;)
>
> I have a php file say
>
> <?
> $query = $_SERVER['QUERY_STRING'];
> $somevar = 'somevalue';
> ?>
>
> i need to dynamically generate some values in the script and output a
> new file to download from it ie
>
> <?
> $query = $_SERVER['QUERY_STRING'];
> $somevar = $this->somevalue;
> ?>
>
> becomes
>
> <?
> $query = $_SERVER['QUERY_STRING'];
> $somevar = 'somevalue';
> ?>
>
> where $this->somevalue is from my generator class ;)
>
> However if I do
>
> $buffer = "<?
> $query = $_SERVER['QUERY_STRING'];
> $somevar = 'somevalue';
> ?>";
>
> I get all sorts of errors around $_SERVER.
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация