Writing to memory and not screen aka echo?

Hi all,

My custom made RSS script extracts data from a PHP file and then generates an XML RSS 2.0 feed. It uses tags hidden within the PHP files to know where to pull data from in the form of:

<rss_content_title> <?php echo $offer_title ?></rss_content_title>

The script works fine.

I now want to expand it to allow for item images in <description> tags found in RSS 2.0 feeds.

My problem is that for this I need to extract the image path from the PHP file. If I do:

<rss_content_image> <?php echo $merchant_store_image_path ?></rss_content_image>

…then that’s fine except of course for the fact that it writes the path on screen. I “could” employ black hat SEO and change the fonts color to the same as the background but that’s bad and likely not worth the risk in this day and age. I could also mask it behind an image in a DIV but it still gets displayed.

I also can’t nest the above tags img src=“” because then the PHP won’t render due to syntax mismatch.

I need to find a way for writing the value of <?php echo $merchant_store_image_path ?> to memory but not screen so my RSS script can then extract this value once it scans the rendered PHP file.

Any clues what to do?

Of course I could do a major revamp and just pull data from MySQL but that’s something for later. For now I just need to get the image path via the method above.

Thanks many,

I tried it but no, then it just outputs “null”.

As I said above, all my brain could think of is to hide it in the img alt=“”. This way it doesn’t get displayed, the search engines won’t mind (i.e. not black SEO) and it’s there for the RSS creator script to parse out.

I guess I could also stuff it in longdesc=“” but since it’s not hardly supported by browsers that could reveal weird behaviour. As such I thought it’s best not to risk it.

Anyway, I’ve got a linked problem to the above over at http://www.sitepoint.com/forums/showthread.php?t=700126 if you guys can/want to help out.

If that content is the RSS feed then surely just getting rid of the word “echo” will fix it.

I’m taking a shot in the dark here, but I believe you’re looking for the output buffering functions, most importantly ob_get_contents

I read your post over and over again but I can’t figure out what your problem is or what it is you are trying to achieve :slight_smile:

Could you try to explain a bit more?

Normally (correct me if I’m wrong) a RSS feed (XML file) is created by reading a page’s content from say a MySQL database.

I’ve designed the site in such a way that it pulls data directly from a PHP page hence no database calls.

Since I needed to store the content’s image path somewhere within my custom tags, I had to find somewhere where to stuff it so it doesn’t get displayed on the PHP page but rather gets echo-ed out in the code.

Given that my above suggestion about using an img’s alt=“” is all I could muster, I ended up doing just that.

The section of the PHP in question now looks like this:

<a href=“<?php echo $offer_participating_store_link ?>” rel=‘nofollow’ title=“Visit participating store” target=“_self”><img src=“<?php echo $merchant_store_image_path ?>”
width=“<?php echo $merchant_store_image_x ?>” height=“<?php echo $merchant_store_image_y ?>” alt=“<?php echo $merchant_store_image_name ?>
<rss_content_image> <?php echo $merchant_store_image_path ?></rss_content_image><rss_content_image_width> <?php echo $merchant_store_image_x ?>
</rss_content_image_width><rss_content_image_height> <?php echo $merchant_store_image_y ?></rss_content_image_height>” /></a>

And works fine in my RSS script.

The only problem I have now as asked here http://www.sitepoint.com/forums/showthread.php?t=700126 is getting the RSS feed to display the image even though from a syntax point of view all seems fine.

Either my eyes are giving up on me or the RSS namespace/schema must be wrong, or some hidden char stuffing getting in the way.

If you’re good at spotting RSS bugs I would appreciate your help :slight_smile:

Perhaps I should add that at the moment the only idea I have is to hide it in the img’s alt=“”.

The above idea works.

Anyone with more upper class ideas than mine?