Functionality of the email process is done with the help of the mail function Main arguments of the mail function are: Recipient’s email address Subject of the email Body of t
Trang 1OOP Concepts
Session 21
Trang 2 Functionality of the email process is done
with the help of the mail() function
Main arguments of the mail() function are:
Recipient’s email address
Subject of the email
Body of the email
Local mail server for mail() function is
specified in the php.ini configuration file
Type of messages are specified with the
help of the content-type header while
attaching a file to the email
Review
Trang 4Object Oriented Basics
Programming with a data type of a data
structure that is defined with the type of
functions and are performed on the data
structure
Uses for combining the data and the functions
into a single unit or an object
Concept of an object-oriented programming are:
Trang 5Inheritance - I
Creates a new class with the help
of a base class
functions, and methods of the base class are transferred to the newly derived class
inheriting a new class from the base class
Derived class also has its own
Trang 6Note: In PHP, multiple inheritances
are not supported
Trang 7 Object that contains variables and
functions of different data types is a class
Class can be inherited from a base class
to create a new derived class
Derived class uses all the properties of the base class including its own
properties
Class variables are local to its class
Trang 8 class – Uses for declaring a class name
class_name – Specifies the class name
class_variable – Specifies the variable name for
the class
function – Uses for defining a function
function_name() – Specifies the function name
Trang 9Class - Example- I
For example, to enter the
employee details using classes
Trang 11Saving the Class file
includes it in the php file
Includes the empdet.inc file in
the php file in the following
format:
include “empdet.inc”;
Trang 12Inheriting a Class
A new class can be inherited from an old class
the parent class along with its own properties
Trang 13Syntax for Inheriting a Class
Syntax for inheriting a new class
Trang 16that of its class name is a
constructor
Uses new operator for calling
constructor in the main program That
is creating a request for the class
the class when a constructor is
declared
Trang 17 class – Uses for declaring a class name
class_name – Specifies the class name
class_variable – Specifies the variable name for the class
function – Uses for defining a function
Trang 18Constructor - Example - I
For example, to call a constructor from a
derived class from a base class
Trang 20Create and Use Objects
Self-contained entity those consists of both
data and procedures to manipulate the data It
Trang 21 new – Initializes the object
class_name – Specifies the class name
Trang 22Creating an Object - Example
For example, create an object for the class
usermail
<?php
class usermail
{
var $username = “john”;
var $password = “abc123”;
}
class userdetails extends usermail
{
var $secretquery = “favourite food”;
var $answer = “chinese”;
}
$mail = new userdetails;
echo $mail;
?>
Trang 23data Objects can be manipulated as needed
abstraction, encapsulation, polymorphism, and inheritance
to a derived class It has its own properties
termed as inheritance It is done with the help of the
extends keyword
is a constructor It is called by using a new operator