Re: String passed to object constructor turning into aninstance of that object?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nathan Nobbe wrote:
Why not test for the type of $name at each point of interest in the
SelectBoxOption
constructor?  If you're passing a string value to the constructor it almost
has to be getting changed by the Tag constructor, right ?

  class SelectBoxOption extends Tag {
   function SelectBoxOption($name, $value, $selected=false) {

var_dump(is_string($name));

     parent::Tag("option", $name);

var_dump(is_string($name));

Ah, that gives...  well, it slightly alters the confusion.

Using var_dump(is_string($name)) gives...  two results?

bool(true)
bool(false)

And dumping $name itself gives:

string(8) "Abegweit"
object(SelectBoxOption)#65 (5) { ["attributes"]=> array(1) { [0]=> object(TagAttribute)#66 (3) { ["name"]=> string(5) "value" ["value"]=> string(1) "4" ["hasValue"]=> bool(true) } } ["tagContent"]=> string(8) "Abegweit" ["tag"]=> string(6) "option" ["showEndTag"]=> bool(false) ["children"]=> array(0) { } }

O_o

Just to confirm, I checked a test instance of the site on CentOS 4, with PHP 4.3, and I get one "bool(true)" for each <option> - not two as is happening with PHP 5.2.

-kgd

(I haven't worked with PHP for quite a while, and I never really spent a lot of time getting deep into complex data structures and object hierarchies like this when I was using it. But this behaviour does NOT match what I know of passing values and object references around in any other language.)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux