| 
 Posted by rynato on 12/28/07 17:28 
I have a lengthy 'markup.php' file which consists of functions which 
take as input the various attribute values of HTML tags and spit out 
the HTML tag. My problem is that the function for <input> is 
interpreting '0' as null and because I've written the functions so 
that they don't write out the attributes which have null value, it 
doesn't generate a 'value="0"' attribute for <input>. 
 
Simplified example: 
 
function input($value=null) { 
 
$input = '<input'; 
if ($value) 
  $input .= ' value="' . $value . '"'; 
else 
  if ($type == 'checkbox' || $type == 'radio') 
    echo('you must specify a value for the attribute "value" of 
<input>'); 
$input .= ' />'; 
return $input; 
} 
 
So... my question is, how - when passing the argument '0' for $value - 
do I make PHP understand that 0 is not null, and so it should go ahead 
and write 'value="0"' instead of throwing my error msg? 
 
thx in adv
 
  
Navigation:
[Reply to this message] 
 |