I have a function with couple of variables in the external file
include 'external.php'; 
and it has:
function external ($username){
    $subjectreq = "Subject";
    $message = '
        <html>
            <head>
                <title>Hi '.$username.'</title>
            </head>
            <body>
                <p>Hi '.$username.'</p>
                <table style="background: #fff;marg in: 2px;padding: 5px 10px;border:1px solid #999;">
                    <tr>
                      <td>Somebody would like to add you among friends.</td>
                    </tr>                           
                    <tr>
                      <td>Please visit this site to accept the request.</td>
                    </tr>                               
                </table>
            </body>
        </html>';
    }
Then I created a class where I'm trying to call this function but it is not working:
include 'external.php'; 
    class FriendLoad {
          public function __construct(){
             add_friend();
          }
        private function add_friend(){
            // select user email and names
            $select = $this->db_connection->prepare("SELECT * FROM  users WHERE user_id= :friend_user_id");
            $select->bindParam(':friend_user_id', $friend_user_id, PDO::PARAM_INT);
            $select->execute();
            $to = "";
            $username = "";
            while($row = $select->fetch(PDO::FETCH_ASSOC)) { $to .= $row['user_email']; $username .= $row['user_name']; }
             external($username);
            $headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
            $headers .= 'From: "Bla" <bla@bla.com>' . "\r\n" ;
            mail($to, $subjectreq, $message, $headers); 
        }
    }
    $friendload = new FriendLoad();
I'm not sure why calling function external(); this way isn't working. I'm getting undifined variables $message and $subjectreq. Any idea?
 
     
     
    