CONCEPTS OF CLASS AND OBJECTS IN PHP ALONG WITH MY OWN GIVEN REAL LIFE EXAMPLES

 CONCEPTS OF CLASS AND OBJECTS IN PHP ALONG WITH MY OWN GIVEN REAL LIFE EXAMPLES

Hi all, a very good morning. Today I am going to explain about the concepts of class and objects along with some real real life examples. So, without wasting time, let's begin with the explanation.

So, first of all let's discuss about the concepts of class. So, guy's what is class?

Class is a container, which contains group of variables, functions and other class objects. We can also say that class is the blueprint of objects. Now coming to some real life examples of class. So, some real life examples of class are like school class, college class, tuition class, etc. and I think no other real life examples of class can be as best as the above real life examples.

Now, let's discuss about the concepts of object. So, guy's what is object?

Object is the instance of a class. Now coming to some real life examples of object. So, some real life examples of object are like table, chair, desktop, laptop, we the human beings, etc this are all real life examples of objects. And I think no other real life examples of object can be as best as the above real life examples. 

Like if within a class their is function, we can't call the class directly, object is used to define to call the class as $obj as because object is the instance of a class.

For example =>

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Registration Form</title>

<style type="text/css">

.c1{

background-color: lightcoral;

color: azure;

text-align: center;

font-size: 40px;

}

.c2{

text-align: center;

}

.c3{

text-align: center;

background-color: burlywood;

color: rebeccapurple;

font-weight: bolder;

}

.c4{

background-color: aliceblue;

color: chocolate;

font-weight: bolder;

font-size: 20px;

}

</style>

</head>

<body>

<h3 class="c1">Simple Registration Form</h3>

<div class="c2">

<img src="https://media.istockphoto.com/id/1463013729/photo/online-registration-form-for-modish-form-filling.jpg?s=612x612&w=0&k=20&c=Fnx06haU4IHYLcRpy9Po_TBknvBqVjicGuUWkGu8e6Y=" height="250px" width="250px">

</div>

<form class="c3">

<fieldset>

Type: <input type="radio" name="type" value="personal">Personal

<input type="radio" name="type" value="company">Company<br>

Email: <input type="email" name="email"><br>

Name: <input type="text" name="name"><br>

Password: <input type="password" name="password"><br>

Gender: <input type="radio" name="gender" value="male">Male

<input type="radio" name="gender" value="female">Female<br>

<button type="submit" name="submit" value="submit" class="c4">Submit</button>

</fieldset>

</form>

<?php

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

$Type=$_REQUEST['type'];

$Email=$_REQUEST['email'];

$Name=$_REQUEST['name'];

$Password=$_REQUEST['password'];

$Gender=$_REQUEST['gender'];

class RegistrationForm

{

function __construct($Type,$Email,$Name,$Password,$Gender)

{

$this->ty=$Type;

$this->em=$Email;

$this->na=$Name;

$this->pa=$Password;

$this->ge=$Gender;

}

function display()

{

echo $this->ty."<br>".$this->em."<br>".$this->na."<br>".$this->pa."<br>".$this->ge;

}

}

$obj=new RegistrationForm($Type,$Email,$Name,$Password,$Gender);

$obj->display();

}

?>

</body>

</html>

Comments

Popular posts from this blog

Programmings Based On Array And String Functions To Merge The 2 Arrays, Then After Merge Convert Into String And Then Find Out The 1st And Last Word From The Reverse String

PHP WEB DEVELOPMENT INTERVIEW QUESTIONS ASKED IN APOLLO HOSPITAL ALONG WITH MY OWN CONCEPTS AND MY OWN EXPLANATION ANSWERS(PART - 1) REST OF THE QUESTIONS AND ANSWERS WILL BE PREPARED BY ME IN MY NEXT BLOG

Mini Project On Multi User CRUD Operations(Create, Read, Update & Delete) Of Donar Details Of Indian Nationals Who Donate To Ramkrishna Math, Belur Math Using PDO (PHP Data Objects) With Proper Explanation Of Each And Every Individual Line Of The Code Of connection.php Page, form.php Page, formaction.php Page, admin_display.php Page, client_display.php Page, edit.php Page, editaction.php Page And delet.php Page (Here You Will Find The Image Of Sayang Sri Ramkrishna Dev, Sayang Sri Ma Sarada Devi & Sayang Sri Swami Vivekananda) In My CRUD Operation