Re: Passing Array to object

From: Date: Wed, 25 Jun 2003 18:08:57 +0000
Subject: Re: Passing Array to object
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-152847@lists.php.net to get a copy of this message
yea, I gave that a shot, Same message. Logically it makes sense, but php doesnt like it. by the way, thanks for your help Chris. You've helped me in the past. -Daniel ----- Original Message ----- From: "Chris Sherwood" <csherwood@nortialearning.com> To: "Daniel J. Rychlik" <drychlik@tcsconsult.com>; <php-general@lists.php.net> Sent: Wednesday, June 25, 2003 1:02 PM Subject: Re: [PHP] Passing Array to object > Have you tried to assign the array to a variable then pass the variable to > the function ie > > $index = new main(); > $yourvar = array('array values'); > > > $index->SetLink ($yourvar); > > ----- Original Message ----- > From: "Daniel J. Rychlik" <drychlik@tcsconsult.com> > To: <php-general@lists.php.net> > Sent: Wednesday, June 25, 2003 10:46 AM > Subject: [PHP] Passing Array to object > > > Hello, > > I am developing a site that uses classes to reuse code and objects. > > I have in my main class a > > function SetLinks($newlinks) { > > $this->links = $newlinks; > > } > > And another function that displays them in the same class main { > > > I have another file called index.php that basically just passes attributes > to the main class and the main class displays them. > > Im having a bit of trouble passing an array to the object > > in the index.php > > I create new. > > $index = new main(); > $index->SetLink = array ( 'Link1' => 'link1.php', > ..... ); > > When I run I recieve "Variable passed to each() is not an array or object " > > so I tried this > > $index->SetLink($newlink = array('link1' => ...); > > same error message. I was wondering if someone could shed some light on > what Im doing wrong. > > Thanks > Daniel >

« previous php.general (#152847) next »