By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,722 Members | 1,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,722 IT Pros & Developers. It's quick & easy.

How can I make an array available to all functions with in a class

P: n/a
I unsuccsessfully tried the following:

class myclass {
$this->$myvariable[1]=20;
$this->$myvariable[2]=20;

function myfuction1{
print $this->$myvariable[1];
;
}

function myfuction2{
print $this->$myvariable[2];

}
} //end of myclass;
Thanks
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Perdit <cf*********@hotpop.com> wrote:
I unsuccsessfully tried the following:
No kidding... where did you grt the idea this would work...?
class myclass {
$this->$myvariable[1]=20;
$this->$myvariable[2]=20;

^this '$' shouldn't be here (repeated twice below)

Also you are creating an array "dynamibaly".
correct syntax:
var myvariable=array(20,20);

Please (re)read the classes related documentation on php.net.

--

Daniel Tryba

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.