Re: Getting an include file into a string after PHP evaluates the vars?

From: Date: Wed, 30 Jan 2002 23:02:23 +0000
Subject: Re: Getting an include file into a string after PHP evaluates the vars?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-82840@lists.php.net to get a copy of this message
how you suggest the solution is what I use all the time. But I thought you wanted to work with is as a string. sorry for the confusion. Jim Lucas ----- Original Message ----- From: "Kevin Stone" <kevin@helpelf.com> To: "'Jim Lucas [php]'" <jimphp@bend.com>; <php-general@lists.php.net> Sent: Wednesday, January 30, 2002 12:12 PM Subject: RE: [PHP] Getting an include file into a string after PHP evaluates the vars? > Actualy I found it's even easier Jim.. > > ob_start(); > include("templates/$card[template].html"); > $output = ob_get_contents(); > ob_end_clean(); > > The include() between the start and clean ob_*() functions won't print > to the client browser yet still evaluates the <?php?> tags within the > HTML template. > > I must say this is a very cool set of functions. Thanks for the tip! > > -- > Kevin Stone > Kevin@helpelf.com > > > -----Original Message----- > > From: Jim Lucas [php] [mailto:jimphp@bend.com] > > Sent: Tuesday, January 29, 2002 6:42 PM > > To: Kevin Stone; php-general@lists.php.net > > Subject: Re: [PHP] Getting an include file into a string after PHP > > evaluates the vars? > > > > yes, there is a way out, you can use readfile(). > > capture the output using ob_*() functions and then parse/eval that > string > > > > listed here are the functions you'll need. > > http://www.php.net/manual/en/function.readfile.php > > http://www.php.net/manual/en/function.ob-start.php > > http://www.php.net/manual/en/function.eval.php > > > > Jim Lucas > > ----- Original Message ----- > > From: "Kevin Stone" <kevin@helpelf.com> > > To: <php-general@lists.php.net> > > Sent: Tuesday, January 29, 2002 3:51 PM > > Subject: [PHP] Getting an include file into a string after PHP > evaluates > > the > > vars? > > > > > > > I'm using templates to create an interface for a new ePostcard > script. > > > The templates are HTML with embedded PHP tags in the likely > positions > > > (ie. font, text, bgcolor, etc..). The script include()'s the chosen > > > template file and evaluates the variables stored in the active > session > > > for display in the browser. > > > > > > I don't know why I didn't think of this ahead of time but in order > to > > > produce the HTML-based ePostcard email I have to get the evaluated > > > template into a string. > > > > > > I can fopen() the template file and read it into a string but the > PHP > > > won't evaluate. And since most of the template is HTML with some > > > Javascript of course eval() won't work on the string. > > > > > > Did I paint myself into a corner here? Or is there a way out that I > > > just don't see. > > > > > > Thanks, > > > Kevin Stone > > > kevin@helpelf.com > > > www.helpelf.com > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#82840) next »