The same code used as below works fine, but when you un-comment the function and try to call the function, it does not behave the same? Am trying to standardize the CRUD using functions, but running into issues.
- The print_r does not display the output when called inside a function but works when called as is outside of a function
 - the return value does not return when called via a function
 - I would like to get the return values via the function and decide what to do next.
 
Appreciate if you could help me out. Thanks
<?php
    //function verifyemail($p_email) {
        echo "insde function - " . $p_email;
        try {
            //      $p_email = "r@gmail.com";
            include 'db.php';
            connectDB('msme_db',1) ;
            $sql = "select count(*) as p_exists from    msme_users where user_email = '$p_email' ;" ;
            echo $sql ;
            $result = $__conn->prepare($sql);
            $result->execute();
            $result->setFetchMode(PDO::FETCH_ASSOC);
            $row = $result->fetch() ;
            //print_r ($row);
            if ($row)
            {
                $i = $row['p_exists'] ;
                return $row !== false ? $row : 'x';
            } 
       } catch (PDOException $e) {
            echo  " in catch" ;
            die("Error occurred:" . $e->getMessage());
       }
//} // End of Function
//$email = "r@gmail.com";
//echo sprintf('Email %s is %s', $mail, verifyemail($email)) ;
print_r($row) ;
?>