Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Quick Variable Assignment In Class Constructor

DZone's Guide to

Quick Variable Assignment In Class Constructor

·
Free Resource
When creating a new object, pass the initial variables as an array. Then use this code to quickly assign the array vars to the class vars.
This will mean importing large arrays into the object in three lines of code. Sex Stories Post - free sex stories, porn stories Erotic Stories 



   $data) {
                                # Don't forget the ';' at the end of the statement inside eval()
				eval("\$this->$key = \$data;");
			}
			$this->printName();
		}
		
		public function printName() {
			print("{$this->first_name} {$this->middle_name} {$this->surname}\n");
		}
	}
	
	$greg = new person(array("first_name" => "Gregory", "middle_name" => "Alexandra", "surname" => "Peck"));
	
?>

 Sex Stories Post - Teens fucked at poolside. Teen lesbian group kansas city Erotic Stories 
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}