Need help with include files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Radiator251
Forum Newbie
Posts: 3
Joined: Sat Nov 08, 2008 10:05 am

Need help with include files

Post by Radiator251 »

I know C+ and I'm currently learning PHP. I have an include file that looks like this (it is called feeds.php):

Code: Select all

<?php
    $rss1 = "";
    $rss2 = "";
    $rss3 = "";
    $rss4 = "";
    
    // Economy feeds
    $feed_Economy1          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/economy/index_xml";
    $feed_Economy2          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/government/index_xml";   
    $feed_Economy3          = "http://online.wsj.com/xml/rss/3_7014.xml";   
    $feed_Economy4          = "http://online.wsj.com/xml/rss/3_7086.xml";
?>
And I'm including it in another file using <?php include("feeds.php"); ?> at the top of the file.

However, when I try to call a variable from the include file, nothing happens.

I write, for instance:

Code: Select all

echo $feed_Economy1;
just to see if it works, and nothing shows up. Is there something special I have to do to tell the file where $feed_Economy1 comes from?

-Yes, I have the URL correct for the include.

Thanks in advance.
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: Need help with include files

Post by Syntac »

Are you echoing the variable before or after the include statement?
Radiator251
Forum Newbie
Posts: 3
Joined: Sat Nov 08, 2008 10:05 am

Re: Need help with include files

Post by Radiator251 »

After.
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: Need help with include files

Post by Ziq »

Is there something special I have to do to tell the file where $feed_Economy1 comes from?
No

Try this.

Code: Select all

 
<?php
    $rss1 = "";
    $rss2 = "";
    $rss3 = "";
    $rss4 = "";
   
    // Economy feeds
    $feed_Economy1          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/economy/index_xml";
    $feed_Economy2          = "http://feeds.washingtonpost.com/wp-dyn/rss/business/government/index_xml";   
    $feed_Economy3          = "http://online.wsj.com/xml/rss/3_7014.xml";   
    $feed_Economy4          = "http://online.wsj.com/xml/rss/3_7086.xml";
 
    echo 'This is a test message.';
?>
 
Do you see this message?
Radiator251
Forum Newbie
Posts: 3
Joined: Sat Nov 08, 2008 10:05 am

Re: Need help with include files

Post by Radiator251 »

Yeah, when I access the include directly. When I access the file that is including it, I don't see it. Which theoretically would suggest that I have the URL wrong, but I definitely don't.
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: Need help with include files

Post by Ziq »

It's strange... try to add this to a top of main php file before include feeds.php

Code: Select all

 
//...
ini_set('display_errors', 1);
error_reporting(E_ALL);
//...
 
Do you get any errors?
Post Reply