olkhicha_appa Posted March 24, 2007 Share Posted March 24, 2007 folks, I am writing a RSS feed as below. You will notice that, in <link> </link> tabs I am trying to output a PHP variable value (which is a URL)Problem is that although I see the value being output OK on commandline execution on the server, e.g. %php foo.php, when I load the page in the browser, the out put for that variable is empty!! i.e. If I see the page source then I dont see <link>value-of-the-variable</link> instead, the tabs show up as <link> </link> I am at my wits end on how to get this working. any ideas? Btw, if I use any PHP function like so: <link> echo date®</link> then I see the page source in browser as <link>24, Mar 2007 12:00 -6:00 </link> which is as expected. ------- <?php header("Pragma: no-cache"); echo '<' . '?xml version="1.0" encoding="UTF-8"?' . '>'; ob_start(); echo shell_exec("foo.sh"); $feed = ob_get_contents(); ob_end_clean(); ?> <rss version="2.0"> <channel> <title>some title</title> <link><?php echo $foo></link> <description>Some description</description> <lastBuildDate><?php echo date® ?></lastBuildDate> <language>en-us</language> <item> <title>Some title</title> <link><?php echo $feed ?></link> <guid><?php echo $feed ?></guid> <pubDate><?php echo date®?></pubDate> <description> </description> </item> </channel> </rss> Link to comment https://forums.phpfreaks.com/topic/44120-php-variables-dont-show-up/ Share on other sites More sharing options...
shaunrigby Posted March 24, 2007 Share Posted March 24, 2007 Change <link><?php echo $foo></link> To <link><?php echo $foo; ?></link> Link to comment https://forums.phpfreaks.com/topic/44120-php-variables-dont-show-up/#findComment-214249 Share on other sites More sharing options...
olkhicha_appa Posted March 24, 2007 Author Share Posted March 24, 2007 Tried that but no change. Link to comment https://forums.phpfreaks.com/topic/44120-php-variables-dont-show-up/#findComment-214256 Share on other sites More sharing options...
shaunrigby Posted March 24, 2007 Share Posted March 24, 2007 Where is $foo actually defined? Link to comment https://forums.phpfreaks.com/topic/44120-php-variables-dont-show-up/#findComment-214258 Share on other sites More sharing options...
olkhicha_appa Posted March 24, 2007 Author Share Posted March 24, 2007 I think I found out the problem though I cant explain the reason. The analysis follows (which also answers your question shaunrigby) $foo is output of shell script like thus: $foo = `./shell_script`; Now, the shell_script is nothing but a simple find command which looks for files in directory named on todays date like thus: shell_script: find `date` -name "foo.txt" So, ultimately, I would like $foo to contain the results of 'find' command. This was not working. So after I redirected the results of find to a plain-text file and then did $foo=`cat results` It worked. Is there any better way to do this in PHP itself? Link to comment https://forums.phpfreaks.com/topic/44120-php-variables-dont-show-up/#findComment-214280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.