<?php




/**
 * 
 * 
 * 
 * Autoloading: is a mechanism that automatically loads required class files when they are needed.
 *  PHP provides native support for autoloading through the SPL function.
 * 
 * Autoloading with SPL (spl_autoload_register):
 * The function spl_autoload_register() allows you to register
 * a custom function that will be called automatically when you try to use a class that hasn't been loaded yet.
 * 
 */


class DB {

    public $name = "Jack";
    public $email;


    private $phoneNumber = "010993882723";


    private $phoneNumber2;


    private $passCode;

    public function printPassword($password) {

        return "here is my $password";
    }


    public function printInfo($password) {

        return "this is the name of the user " . $this->name . " and here is the password " . $this->printPassword($password);

    }


    public function setNumber($num) {


        if(strlen($num) > 15) {


            echo false;
        }

        $this->phoneNumber2 = $num;

        return true;
    }



    public function getNumber() {

        return $this->phoneNumber2;
    }


    // public function __construct($name) {

    //     $this->name = $name;
    //     echo "user " .  $this->name . " is created";
    // }

    // public function __destruct() {
    //     echo "<br>" . "object is destroyed and so as the user: " . $this->name;
    // }


    public function setPass($passCode) {


        if($passCode !== "mohamed123444") {

            return false;
        }

        $this->passCode = $passCode;
    }


    public function getPass() {

        return $this->passCode;
    }

} 


$db = new DB("Mohamed");

$db->setPass("mohamed12344");

$db->getPass();

echo($db->getPass());

//echo $db->phoneNumber;

// $db->setNumber("019993828");
// echo $db->getNumber();
// var_dump($db);

