| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
max() on undefined parameters does not assume the value is zero, it ignores it.
<?php
$dimensions = array('left' => -2);
// If $dimensions['right'] was never set,
// we may expect it to be treated as zero, but
print max($dimensions['left'], $dimensions['right']);
//
// Returns -2, not zero
<?php
print max(0+$dimensions['left'], 0+$dimensions['right']);
?>
would be a work-around, but it's probably tidier to ensure your values are set correctly first.
(on PHP 5.2.11 anyway)
----
Server IP: 202.89.58.1
Probable Submitter: 121.74.105.72
----
Manual Page -- http://www.php.net/manual/en/function.max.php
Edit -- https://master.php.net/note/edit/98048
Del: integrated -- https://master.php.net/note/delete/98048/integrated
Del: useless -- https://master.php.net/note/delete/98048/useless
Del: bad code -- https://master.php.net/note/delete/98048/bad+code
Del: spam -- https://master.php.net/note/delete/98048/spam
Del: non-english -- https://master.php.net/note/delete/98048/non-english
Del: in docs -- https://master.php.net/note/delete/98048/in+docs
Del: other reasons-- https://master.php.net/note/delete/98048
Reject -- https://master.php.net/note/reject/98048
Search -- https://master.php.net/manage/user-notes.php