RE: putting the result of PHP code into a string

From: Date: Sun, 11 Nov 2001 23:15:47 +0000
Subject: RE: putting the result of PHP code into a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74192@lists.php.net to get a copy of this message
I have an parse error ... <? $val="test"; $code = <<<ENDM echo "<b>$val</b>\n"; ENDM; ?> at line 3 :-( AK>-----Original Message----- AK>From: Morten Gjetanger [mailto:mortengj@yahoo.com] AK>Sent: Saturday, November 10, 2001 6:46 PM AK>To: php-general@lists.php.net AK>Subject: Re: putting the result of PHP code into a string AK> AK> AK>Ok. To be a bit more precise. the $code part could be any php code, e.g. AK> AK>$code = <<<ENDM AK> AK>require_once("someFile.inc"); AK> AK>$array1 = someFunc1($param1); AK> AK>foreach($array1 as $val) { AK> echo "<td>$val</td>\n"; AK>} AK> AK>ENDM; AK> AK>regards AK> AK>Morten Gjetanger AK> AK>"Morten Gjetanger" <mortengj@yahoo.com> skrev i melding AK>news:20011109213619.53562.qmail@pb1.pair.com... AK>> I'm quite sure there is a simple solution to the problem bellow! AK>> AK>> I like to evaluate som PHP code, but I want the result to be AK>putted into a AK>> string. AK>> AK>> example: AK>> AK>> $var = "Test1"; AK>> $code = "<td><?php echo $var1?></td>"; AK>> $html = someFunction($code); AK>> AK>> After this i want $html to contain "<td>Test1</td> AK>> AK>> I've checked the eval function, but it just evaluates the code and just AK>> outputs the result. I really wants the output into a string! AK>> AK>> regards AK>> AK>> Morten Gjetanger AK>> AK>> AK> AK> AK>

« previous php.general (#74192) next »