You are here: Re: evaluate code before serving it « PHP Programming Language « IT news, forums, messages
Re: evaluate code before serving it

Posted by Sander Tekelenburg on 07/24/07 20:51

In article <op.tvzecvwtqnv3q9@metallium>,
Rik <luiheidsgoeroe@hotmail.com> wrote:

> On Tue, 24 Jul 2007 19:59:27 +0200, Sander Tekelenburg
> <user@domain.invalid> wrote:
>
> > [...] Each file
> > contains HTML and now and then some embedded PHP snippets.
> >
> > [...] I need to first evaluate those PHP snippets,
> > store the result in a variable, and use *that* as the input for the RSS
> > generator script.

[...]

> ob_start();
> eval('?>'.file_get_contents('file.php').'<?php');
> $string = ob_get_clean();

Yeah, I had tried that. But for some reason this results in $string
being (defined but) empty.

> Then again, that would basically be the same as:
> ob_start();
> include('file.php');
> $string = ob_get_clean();

Bingo! That works. Thanks!

[...]

> It could be that your RSS-generator only swallows files/urls, and not
> strings?

It eats strings. I'm making use of FeedCreator.class.php. See
<http://www.bitfolge.de/rsscreator-en.html>

So the code essentially is this:

require_once("feedcreator.class.php");
$news = new UniversalFeedCreator();
//loop through list of news files
ob_start();
include($s_pathtofile);
$s_content = ob_get_clean();
$item = new FeedItem();
$item->description = $s_content;
$item->addItem($item);
//end loop
$news->saveFeed("RSS1.0", "path/file.xml", false);

> In that case:

[...]

> //write output to temporary file [...]

Yeah, I was considering going there. Glad I don't have to :)

--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>

Mac user: "Macs only have 40 viruses, tops!"
PC user: "SEE! Not even the virus writers support Macs!"

 

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

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