Froggy
11-05-2005, 07:45 AM
I noticed something that I take as odd behavior for php (I'm using php 5.0.5), say you have a class:
class Blah {
private $name;
function __contruct($name){ $this->name = $name; }
function getName(){ return $this->name; }
}
Now lets say you have an array (call it $array) and you do this:
$blah = new Blah();
$array[$blah->getName()] = $blah;
If you do this you get an "Illegal Offset type" error, where as if you caste the $blah->getName() to string if works fine....anybody know why this is the case? I would figure php would automatically do this...
class Blah {
private $name;
function __contruct($name){ $this->name = $name; }
function getName(){ return $this->name; }
}
Now lets say you have an array (call it $array) and you do this:
$blah = new Blah();
$array[$blah->getName()] = $blah;
If you do this you get an "Illegal Offset type" error, where as if you caste the $blah->getName() to string if works fine....anybody know why this is the case? I would figure php would automatically do this...
