1. Trang chủ
  2. » Mẫu Slide

Slide môn học PHP session 8b OOP concepts

23 537 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 23
Dung lượng 91,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

 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 1

OOP 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 4

Object 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 5

Inheritance - 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 6

Note: 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 9

Class - Example- I

 For example, to enter the

employee details using classes

Trang 11

Saving 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 12

Inheriting a Class

 A new class can be inherited from an old class

the parent class along with its own properties

Trang 13

Syntax for Inheriting a Class

 Syntax for inheriting a new class

Trang 16

that 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 18

Constructor - Example - I

 For example, to call a constructor from a

derived class from a base class

Trang 20

Create 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 22

Creating 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 23

data 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

Ngày đăng: 30/11/2016, 22:12

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN