PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function myFunction() {
$myDbObject = new DbObject;
$myDbObject->dbOpen();
$records = $myDbOject->getRecords();
if (mysql_num_rows($records) > 0) {
echo ("success!");
return TRUE;
}
$myDbObject->dbClose();
}
Does the dbClose method of myObject get fired before myFunction sends control back to the calling routine? Or does return TRUE; happen after the entire function is handled?
As soon as a return is executed then the function ends, no more code is executed afterwards. In this case if your IF statement evaluated to true, then the function would return true and dbClose() would never be executed.