clankill3r Posted November 10, 2011 Share Posted November 10, 2011 i have: class Host { public $hostname; public $foundResults; public function __construct($hostname) { $this->$hostname = $hostname; $foundResults = array(); } } but when i create a object the hostname doesn't get set, instand a new propert get's created What do i do wrong? Host Object ( [hostname] => [foundResults] => [www.google.nl] => www.google.nl ) Link to comment https://forums.phpfreaks.com/topic/250901-set-value-for-class/ Share on other sites More sharing options...
requinix Posted November 10, 2011 Share Posted November 10, 2011 $this->$hostname = $hostname; Too many $s. You only need the first one on $this. $this->hostname = $hostname; And you're missing the $this-> for foundResults. Link to comment https://forums.phpfreaks.com/topic/250901-set-value-for-class/#findComment-1287213 Share on other sites More sharing options...
clankill3r Posted November 10, 2011 Author Share Posted November 10, 2011 thx Link to comment https://forums.phpfreaks.com/topic/250901-set-value-for-class/#findComment-1287214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.