How do output data from another PHP file?

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
uusrand
Forum Newbie
Posts: 2
Joined: Wed Jul 21, 2010 3:10 am

How do output data from another PHP file?

Post by uusrand »

Hallo!

How do output data from another PHP file "1.php" (file is with XML construction).

"1.php" code:
<meteodata time="2010-07-21">
<data id="temp">23.35</data>
<data id="humid">72.14</data>
</meteodata>

On file "2.php" should be a lines what print the data of "temp" and "humid"
echo "<a href=\"http://.../1.php" </a>";
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: How do output data from another PHP file?

Post by Gargoyle »

Code: Select all

echo file_get_contents('1.php');
note that you will have to address the file through http unless you want the php code.
uusrand
Forum Newbie
Posts: 2
Joined: Wed Jul 21, 2010 3:10 am

Re: How do output data from another PHP file?

Post by uusrand »

Thanks.

But how can I get only data, if example data id="temp"
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: How do output data from another PHP file?

Post by Gargoyle »

so you actually want to parse XML data?

check this out:
http://www.php.net/manual/en/ref.xml.php
Post Reply