I am having problem fetching return value returned by a class function in PHP. Does returning values works exactly the way it works in other languages- C, C++, Java or there is something new to it.
This is my Class:
class M_UserMaster
{
private $_db = null;
function __construct($db)
{
$this->_db = $db;
}
function checkUserExists($mobNum)
{
$userExists = false;
$sql = "SELECT STATEMENT HERE";
$stmnt = $this->_db->prepare($sql);
$stmnt->execute();
$numRows = $stmnt->rowCount();
echo '<br><br>Num Rows: ' . $numRows . '<br>***';
$userExists = ($numRows > 0) ? true : false;
return $userExists;
}
}
The echo statement returns 0. But the function returns nothing.
From another file I am calling it like this:
$m_userMaster = new M_UserMaster($db);
$userExists = $m_userMaster->checkUserExists('0000000000');
echo '<br><br>User Exists: ' . $userExists;
This is what is printed
User Exists: