Tommy Pham wrote:
   class SelectBoxOption extends Tag {
     function SelectBoxOption($name, $value, $selected=false) {
       parent::Tag("option", $name);
       $this->addAttribute("value", $value);
       if($selected) {
         $this->addAttribute("selected", '', false);
if ($name == "") { echo "&nbsp;&nbsp;&nbsp;missing name!<br>\n"; }
//  else { print "&nbsp;&nbsp;&nbsp;name $name<br>\n"; }
if ($value == "") { echo "&nbsp;&nbsp;&nbsp;missing value!<br>\n"; }

will parse and execute, but:
- the page will contain "missing value!" for each <option> in the
<select> this is generating
- it will *not* contain "missing name!"
- the <option> tags in the final output don't have content or value
(they should have both).

If I uncomment that else, I get:

adding option <name1> with <value1>
     name <value1>

  Catchable fatal error: Object of class SelectBoxOption could not be
converted to string in
on line 12

What's the actual line #12 in the file SelectBoxOption.php?  The
SelectBoxOption code you presented has 11 lines unless it's a CNP error.

Whups, thought I noted that. I trimmed a couple of blank lines; line 12 in the file is that print in the else.

I found trying to print $name triggers the same error anywhere in that function, too; as I noted further down it seems the string that's passed in is getting mutated into an object. (Whose missing toString function is what led me here - but it works fine in PHP 4.3...)


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to