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 ) Quote 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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/250901-set-value-for-class/#findComment-1287214 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.