is there a way to kill a script if an error occured?
ex:
if the first if statement works, the function will return 1 even if !is_array($array). i know this wasn't the best example, but it serves its purpose.PHP Code:function loop_me($array, $obj)
{
if (emtpy($obj->name))
die('Name not set in object');
foreach ($array as $a)
{
if ($a > 1)
echo 'BOOM!';
}
return 1;
}
[edit]
i guess doing an if statement might work (but looks kinda crude)
PHP Code:function loop_me($array, $obj)
{
$return = 0;
if (emtpy($obj->name))
die('Name not set in object');
if (1 == 1)
{
foreach ($array as $a)
{
if ($a > 1)
echo 'BOOM!';
}
$return = 1;
}
return $return;
}






Bookmarks