Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is wrong here

Status
Not open for further replies.

wolf73

Programmer
Feb 12, 2006
93
CA
I am geting error at $this->playarray();, isn't this how we can call memebr function of a class?



<?php


class myarray
{


function playarray()

{
$temparray= array();
$temparray = array ( 'a' => 'you' , 'b' => 'me', 'c' => 'they' );


foreach ($temparray as $simple => $value)
{
echo "Index".$simple. "Value".$value;

}


}
function onemore()

{

myarray::playarray();
$this->playarray();

}
}

myarray::eek:nemore();

?>
 
You are using class and object functions at the same time.

Classfunctions don't have objects, so $this simply doesn't exists.

Try making an object first and then call the functions
Code:
function  onemore()

    {

    $this->playarray();

    }
}

myarray = new myarray()
myarray->onemore();

Or don't use objects and only classes
Code:
function  onemore()

    {

    self::playarray();
    }
}

myarray::onemore();

mcvdmvs
&quot;It never hurts to help&quot; -- Eek the Cat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top