PHP OOPS


PHP OOP Tutorials in Urdu/Hindi Part 6 of 15 This Keyword

<?php

class hello{

        public $name = "Devika Ag";
        public $email = "agrawaaldevika@gmail.com";
        public $mobile = "97186666870";

        public function user(){

        echo "Name:"$this->name . "<br>Email:"$this->email . "<br>Mobile:"$this->mobile;


  }
}


$hello = new hello();


$hello->user();

?>

PHP OOP Tutorials in Urdu/Hindi Part 8 of 15 Magic Function Construct /Predefine Method Name


<?php 


   class world{
         
      public function __construct(){

      echo "World has been connected";
}  
     public function __destruct(){

      echo "World has been disconnected";
}  
      public function hello(){

        echo "Hello World";

          }

}



$w = new world();
?>


PHP OOP Tutorials in Urdu/Hindi Part 9 of 15 Magic Function Autoload


<?php 


public function__autoload($class){
    include "classes/$class.php";


}

include "eena.php";       //
include "meena.php";      //
include "deeka.php";      //

$eena = new eena();
$meena = new meena();
$deeka = new deeka();

echo $eena->name;  "<br>";
echo $eena->email;

echo $meena->name;  "<br>";
echo $meena->email;

echo $deeka->name;  "<br>";
echo $deeka->email;

?>



eena.php

<?php 

class eena{


public $name = "eena";
public $email = "eena@gmail.com";


}
?>
meena.php

<?php 

class meena{


public $name = "meena";
public $email = "meena@gmail.com";


}

?>
deeka.php

<?php 

class deeka{


public $name = "deeka";
public $email = "deeka@gmail.com";


}

?>

PHP OOP Tutorials in Urdu/Hindi Part 10 of 15 Inheritance

<?php  

class countries{

      public $pk = "Pakistan";
      public $af = "Afghanistan";
      public $ind = "India";
      public $jp = "Japan";
      public $us = "United States"; 
}

class players extends countries{

      public $name1 = "Eena";
      public $name2 = "Meena";
      public $name3 = "deeka";

      public function getPlayer(){
      return $this->name1 . "is from" . this->pk; 

}

}
$player = new players();
echo $player->getPlayer();

?>

PHP OOP Tutorials in Urdu/Hindi Part 11 of 15 More on OOP Registeration Form

<!DOCTYPE html>

<head>
<title>
Registeration Form</title>
<style type="text/css">

body{
padding:0;
margin:0;
background:silver;
}
#form{
width:50%
height:400px;
margin:0 auto;
padding:20px;
background:white;
}
input{
display:block;
margin:5px;
height:30px;
width:200px;

}
label{

margin:5px;
font-weight:bold;

}
</head>

<body>
<div id="form">

<form action="form.php" method="post">
<label>Username:</label>
<input type="text" name="username" placeholder="enter user name required="required" />
<label>UserEmail:</label>
<input type="email" name="email" placeholder="enter email" required="required"/>
<label>Password:</label>
<input type="password" name="password" placeholder="enter password" required="required"/>
<input type="submit" name="submit" value="submit"/>


</form>

</body>



</html>

<?php 

include 'process.php';

$db = new db();

if (isset($_POST['submit'])){

$user = $_POST['username'];
$email = $_POST['email'];
$pass = $_POST['pass'];

$query = "INSERT INTO users (user_name,user_email,user_pass) values ('$user', '$email', 'pass') ";

 $db->insert($query);

public function insert($query){

$result = $this->link = query($query);

if($result){
echo "Registeration Succesful";
}
else {

echo "Registeration Failed";
}
}



}


?>

PHP OOP Tutorials in Urdu/Hindi Part 13 of 15 Registration Form Project
Creating Database

process.php

<?php 

class db{


    public $host = "localhost";
    public $user = "root";
    public $pass = " "; 
    public $db_name = "oop";

    public $link;
    public $error;

    publicfunction__construct(){

$this->connect();
}


   private function connect(){

$this->link = new mysqli($this->host,$this->user,$this->pass,$this->db_name)

if (!$this->link){

$this->error = "Connection Failed:"; . $this->link->connect_error;


}

}


}


?>