Assign values to a class var

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
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Assign values to a class var

Post by itsmani1 »

I want to assign a value to my class variable please see the code below. I want to assign an array to $items? can i do this?

If i can do please help me out.

thanks

Code: Select all

class myClass
{
    var $items;
}
 
$obj = new myClass;
funkycode
Forum Newbie
Posts: 9
Joined: Fri Dec 12, 2008 8:17 am

Re: Assign values to a class var

Post by funkycode »

You can assign values like so:

Code: Select all

$obj->items = array();
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Re: Assign values to a class var

Post by itsmani1 »

thanks

I was doing with $items and getting error :)
Post Reply