tags:

views:

33

answers:

4

I have created a simple function for fetching xml:

function meteor(){
    $request_url = "http://site.com/xml.xml";
    $xml = simplexml_load_file($request_url) or die("feed not loading");
    return $xml;
 }

But I cant call to this function:

$xmls = new meteor();
echo $xmls->Kemo->Area;

I have not any output because meteor in not a class. In this situation, how can fetch data from function? Thanks in advance

+5  A: 
$xmls = meteor();
$xmls->Kemo->Area;
faileN
you have earned the speed demon badge (well, it there was one).
Gordon
hehe thanks :) I'll keep that badge on my imaginary almost-badge-collection-table ;)
faileN
+1  A: 

meteor is a function not a class. i don't think you can create a

new meteor();
fabrik
+2  A: 

You can use new only with classes, to create a new object from that class. meteor is a function, not a class. What you want is to call the function instead, simply like this:

$xmls = meteor();
Thomas
+1  A: 

The basic code is wrong. Always remember that you cannot use the "new" keyword for instantiating functions. This "new" keyword will only work for instantiating classes into objects.

Try calling the function directly into your code, for fetching the appropriate value. But before that I think you will need to modify your "meteor()" function according to what you want to achieve.

Hope it helps.

Knowledge Craving