Matthew M.

Matthew M.

Exceptions

Slide Duration:

Table of Contents

Section 1: Advanced PHP with MySQL
Course Introduction

13m 36s

Intro
0:00
Advanced PHP w/ MySQL
0:13
Course Introduction
0:14
Course Content
0:59
Web Application: Educator Store
1:45
Web Application: Educator Store
1:46
Object-Oriented Programming
6:09
Object-Oriented Programming Overview
6:10
MySQL
6:50
MySQL Overview
6:51
Example: Command Prompt & MySQL
8:34
What You Will Learn
9:34
What You Will Learn
9:35
Course Prerequisites
11:52
Course Prerequisites
11:53
Advanced Course Development Environment

18m 46s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Development Environment Setup
1:36
Firefox Web Browser, XAMPP, and PSPad Text Editor
1:37
Course Directory Structure
4:36
Course Directory Structure
4:37
phpDocumentor
7:23
phpDocumentor Overview
7:24
Parsing Source Code
7:44
docs Subdirectory
9:06
Asvanced PHP Course Documentation Example
10:21
Previous Educator PHP Students
14:14
Lib Directory Changes
14:38
Images Directory Changes
14:57
VERSION Constant
15:40
Comments Noting a Specific Version Number
17:04
Homework Challenge
17:30
Homework Challenge
17:31
Introduction to File I/O

35m 37s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
File I/O
1:34
File I/O Overview
1:35
Performing file I/O: 3 Steps
1:52
File Permissions
2:28
Read Permission & Write Permission
2:29
fopen()
4:47
fopen()
4:48
Two Required Parameters
5:01
Successful fopen(): File Handle and Resource
5:21
FALSE and E_WARNING Error
6:00
Example
6:39
File Paths
7:10
File Paths
7:11
File Access Modes
9:18
File Access Modes
9:19
Coding Example: fopen()
10:31
Using Relative and Absolute Path & Non-Existent File
10:32
File Pointers
15:55
File Pointers
15:56
Example File
16:11
Opening a File with fopen() Using 'r' as the Access Mode
16:22
fgets()
17:55
fgets() Overview
17:56
Coding Example: fgets() - Reading a Line at a Time
18:26
feof()
20:10
feof() Overview
20:09
Coding Example: feof()
20:50
fclose()
23:43
fclose() Overview
23:44
Coding Example: fclose()
25:02
Coding Example: Current Stock
26:10
Coding Example: Current Stock
26:11
trim ()
31:39
trim () Overview and Example
31:40
Homework Challenge
33:35
Homework Challenge
33:36
Web Application Development

36m 36s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Version 1.0 Changelog
0:31
catalog.php
0:32
Function Library: fileLIB.php
5:00
Version 1.1 Changelog
27:12
createItemDataArray() and createDeptDataArray()
27:13
outputSimpleItemLink() and outputSimpleDeptLink()
32:06
HTTP & the POST Method

34m 36s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
HTTP Model
1:28
HTTP Model
1:29
Client-Server Model 2 Steps Process
2:00
HTTP Messages
2:23
HTTP Messages
2:24
HTTP Requests
3:09
HTTP Requests
3:10
Example: HTTP Request Header
3:17
Coding Example: HTTP Requests
4:29
HTTP Responses
7:15
HTTP Responses
7:16
Example: HTTP Response (Header & Body)
8:00
header()
11:47
header() Overview
11:48
Coding Example: header
14:02
Coding Example: header() Error
14:52
GET Method
18:55
GET Method
18:56
Coding Example: GET Method
20:13
POST Method
21:09
POST Method
21:10
Coding Example: Sample Form Using the POST Method
23:50
Accessing POST Data in PHP
26:38
Accessing POST Data in PHP
26:39
Coding Example: Accessing POST Data via $_POST
28:15
GET vs. POST
29:54
GET vs. POST
29:55
Example: Accessing POST Data via $_POST
31:20
Example: Accessing POST Data via $_POST
31:21
Homework Challenge
33:00
Homework Challenge
33:01
Web Application Development

14m 11s

Intro
0:00
Version 2.0 Changelog
0:09
Updating the Site's Current Form to Use the POST Method
0:10
Creating Admin Website
2:55
Dynamically Generated Department List
12:40
Writing to Files

17m 38s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Review of File I/O
0:40
Review of File I/O
0:41
fwrite()
1:38
fwrite()
1:39
fputs()
2:20
'r+'
2:31
Coding Example: fwrite()
2:59
fopen() Access Modes
8:41
'a' and 'a+'
8:42
'w' and 'w+'
11:34
Homework Challenge
14:47
Homework Challenge
14:48
Web Application Development

28m 14s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Updated Open File Functions
0:19
openItemsDataFile ( ), openDeptsDataFile ( ), and openLastAddedFile ( )
0:20
insertItem()
6:25
insertItem() Overview
6:26
Functions: createItemDataString ( ) and updateLastItemAdded ( )
7:07
addItemToDepartment ()
16:03
addItemToDepartment () Overview
16:04
Functions: createDeptDataString ( ) and updateDepartment ( )
17:55
HTTP POST: File Uploads

22m 51s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
POST Data Encoding
1:13
POST Data Encoding
1:14
When Data is Included in the Body of the HTTP POST Request and is of the Content Type
1:31
When Uploading Files Using HTTP POST
3:17
Uploading Files
6:22
Uploading Files
6:23
If Encoding Type is Not Set to Multipart/Formdata
9:27
$_FILES Superglobal
10:59
$_FILES Superglobal
11:00
Structure of $_FILES
12:15
Structure of $_FILES: Name, Type, tmp_name, Error, and Size
12:16
Coding Example: $_FILES Superglobal
13:34
Moving an Uploaded File
15:39
Introduction to Moving an Uploaded File
15:40
move_uploaded_file ( ): Definition and Example
16:40
Homework Challenge
21:19
Homework Challenge
21:20
Web Application Development

15m 30s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Uploading Item Image File
1:22
Uploading Item Image File
1:23
Uploading Item Image File (cont.)
2:43
Altering insertItem ( )
2:44
Helpfer Functions: getFileExtension ( ) and moveUploadedFile ( )
4:30
isValidItem ( )
13:03
Introduction to Object-Oriented Programming

32m 44s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object-Oriented Programming
0:56
Introduction to Object-Oriented Programming
0:57
Associative Arrays
5:27
Associative Arrays
5:28
Classes
7:27
Classes Overview
7:28
Defining Classes
8:24
Defining Classes
8:25
Declaring Class Properties
9:25
Coding Example: Classes
10:11
Objects
12:18
Objects Overview
12:19
Classes vs. Objects
12:49
Classes vs. Objects
12:50
Instantiating Classes
14:58
Instantiating Classes
14:59
Coding Example: Instantiate an Item Object
16:30
Object Properties
19:21
Access and Set an Object's Property
19:22
Coding Example: Set & Access the Properties of an Item Object
24:23
Homework Challenge
30:22
Homework Challenge
30:23
Web Application Development

17m 47s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 5.0 Overview
0:50
Version 5.0 Overview and Examples
0:51
Outputting Object Properties
12:38
Outputting Object Properties
12:39
Array Object Properties
14:18
Access and Set Array Value
14:19
Object Methods

39m 57s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Object Methods
0:52
Definition of Object Methods
0:53
Calling Object Methods
3:25
Calling Object Methods
3:26
Coding Example: Simple Object Methods
4:44
Object Methods and Return Values
7:02
$this Variable
10:06
$this Variable: Definition and Example
10:07
$this Variable (cont.)
15:51
$this Variable (cont.)
15:52
Getters & Setters
21:21
Getters & Setters Methods
21:22
Object Methods In Strings
25:46
Object Methods In Strings
25:47
Coding Example: Outputting Method Return Values in Strings
27:41
Using $this to Call Other Methods
28:49
Using $this to Call Other Methods
28:50
Homework Challenge
34:18
Homework Challenge: 1-3
34:19
Homework Challenge (cont.)
36:20
Homework Challenge: 4-6
36:21
Homework Challenge (cont.)
37:52
Homework Challenge: 7-10
37:53
Web Application Development

17m 30s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 6.0 Overview
0:40
Version 6.0 Changes & Examples
0:41
Item Methods
0:53
Item Class Definition: getImageFilename()
0:54
Coding Example: getImageFilename()
1:58
Department Methods
7:33
addItem(), removeItem(), and isItemInDept() Method
7:34
addItemtToDepartment() & buildDeptObject() Functions
11:46
A Default Value Needed to Be Set for $items
16:26
Object Constructors

22m 20s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Object Constructors
0:32
Introduction to Object Constructors
0:33
Coding Example: Object Constructors
1:43
Defining Constructors
3:26
Defining Constructors
3:27
Coding Example: Constructors with No Arguments
4:24
Constructor Arguments
8:09
Constructor Arguments
8:10
Coding Example: Constructor Arguments
9:49
Important Notes
16:13
Important Notes
16:14
Homework Challenge
17:35
Homework Challenge: 1 - 4
17:36
Homework Challenge (cont.)
19:13
Homework Challenge: 5 - 9
19:14
Homework Challenge (cont.)
21:40
Homework Challenge: 10 and 11
21:41
Web Application Development

16m 19s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
Version 7.0 Overview
0:39
Version 7.0 Overview
0:40
Item Constructor
2:19
Item Constructor
2:20
Department Constructor
7:47
Department Constructor
7:48
Customer Constructor
12:23
Customer Constructor
12:24
More Magic Methods

53m 37s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
Magic Methods
1:12
Magic Methods
1:13
Destructors
2:45
Destructors Overview
2:46
Coding Example: Calling Destructors
4:30
Coding Example: Object Destructor
9:19
_to String ()
16:12
_to String () Overview
16:13
Coding Example: _to String () Magic Method
18:10
Access Modifiers
21:23
Introduction to Access Modifiers
21:24
Access Modifiers: Public
21:39
Access Modifiers: Private
22:18
Access Modifiers: Protected
22:41
Object Properties and Methods
23:06
Coding Example: Public Access Modifiers
26:48
Coding Example: Private Access Modifiers
28:30
_get()
31:37
_get() Overview
31:38
Coding Example: _get () Magic Method
33:30
_set ()
36:23
_set () & the Magic Method
36:24
Using Getters & Setters
44:37
Coding Example: Using Getters & Setters
44:38
Homework Challenge
50:33
Homework Challenge: 1 - 6
50:34
Homework Challenge (cont.)
51:41
Homework Challenge: 7 - 12
51:42
Web Application Development

31m 12s

Intro
0:00
Version 8.0 Review
0:12
Version 8.0 Review
0:13
private Object Properties
1:15
private Object Properties
1:16
Coding Example
2:54
_toString() Methods
6:51
_toString() Methods
6:52
Coding Example
8:09
DataFile Class
13:27
DataFile Class & I/O Operations
13:28
Using DataFile Class: Instantiate a DataFile, DataFile open () Method, and DataFile close () Method
18:09
Homework Challenge
29:35
Homework Challenge
29:36
Classes vs. Objects

37m 49s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
Class vs. Object Review
0:58
Class vs. Object Review
0:59
Static Properties
2:42
Static Properties
2:43
Scope Resolution Operator (::)
5:26
Scope Resolution Operator (::) & Static Property
5:27
Coding Example: Accessing a Static Property Using the Scope Resolution Operator
7:57
Coding Example: Accessing a Static Property in a Class Definition
10:33
Coding Example: Using a Static Property as an Instance Counter
14:18
Static Methods
18:51
Static Methods Overview
18:52
Coding Example: Static Methods
21:39
Classes vs. Objects
26:28
Classes vs. Objects: Diagrams
26:29
Class Constants
30:24
Class Constants Definition
30:25
Coding Example: Using Class Constants
31:55
Homework Challenge
34:01
Homework Challenge: 1 - 5
34:02
Homework Challenge (cont.)
35:25
Homework Challenge: 6 - 10
35:26
Web Application Development

21m 7s

Intro
0:00
Version 9.0 Overview
0:12
Version 9.0 Changes & Examples
0:13
Output Class
1:08
Output Class & Static Methods
1:09
outputHtmlSelector ( ) Method
2:43
outputItemSelector ( ) Method
4:53
outputDeptSelector ( ) Method
6:42
buildObject() Methods
11:54
buildObject() Methods & Examples
11:55
Exceptions

22m 43s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
try Blocks
0:44
try Blocks Definition
0:45
catch Blocks
2:03
catch Blocks: Definition and Syntax
2:04
Coding Example: try/catch Blocks
3:48
When an Exception Object is Caught & Error Handling
5:59
Exception Class
7:02
Exception Class
7:03
Coding Example: Using try/catch to Catch an Exception Thrown from a Method
8:04
Re-Throwing Exceptions
16:39
Re-Throwing Exceptions
16:40
Coding Example: Re-throwing an Exception
17:21
Homework Challenge
20:40
Homework Challenge: 1 - 5
20:41
Homework Challenge (cont.)
22:17
Homework Challenge: 6
22:18
Web Application Development

22m

Intro
0:00
Version 10.0 Overview
0:11
Updating addItem.php, addItemToDept.php, and error.php
0:12
Updating DataFile Class: open ( ) Method & try/catch blocks
7:45
Version 10.1 Overview
13:37
Version 10.1 Changes & Examples
13:38
Updating DataFile Class: close ( ) Method & logWarning ( )
20:17
Cookies

39m 47s

Intro
0:00
Lesson Overview
0:09
Lesson Overview
0:10
What is a Cookie?
1:15
Definition of Cookie
1:16
HTTP - A Stateless Protocol
2:17
HTTP - A Stateless Protocol
2:18
Purpose of Cookies
4:10
Set - Cookie Header
6:21
Introduction to Set - Cookie Header
6:22
Coding Example: Set - Cookie Header
7:38
Cookie Header
9:45
Introduction to Cookie Header
9:46
Example: Cookie Header
10:27
setcookie()
12:33
Introduction to setcookie()
12:34
Example: Using setcookie
13:54
Cookies Attributes
15:48
Cookies Attributes Overview
15:49
Common Cookies Attributes: Domain
16:24
Common Cookies Attributes: Path
17:04
Common Cookies Attributes: Expires
19:34
Coding Example: Setting Cookie Attributes
20:58
$_COOKIE Superglobal
27:03
$_COOKIE Superglobal
27:04
Coding Example: Accessing Cookies from PHP Using $_COOKIE
29:45
Security Implications
34:44
Security Implications
34:45
Homework Challenge
36:10
Homework Challenge: 1 - 4
36:11
Homework Challenge (cont.)
37:47
Homework Challenge: 5 - 7
37:48
Web Application Development

39m 11s

Intro
0:00
Lesson Overview
0:17
Lesson Overview
0:18
instanceof Operator
1:34
instanceof Operator
1:35
Objects with Object Properties
2:53
Objects with Object Properties
2:54
Version 11.0 Overview
6:41
Version 11.0 Changes: Cart and CartItem Classes
6:42
Version 11.0 Coding Example
10:40
Version 11.1 Overview
31:03
Version 11.1 Changes & Examples
31:04
Introduction to Sessions

46m 8s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
What is a Session?
0:53
What is a Session?
0:54
Client-Side Sessions
3:51
Client-Side Sessions
3:52
Server-Side Sessions
5:04
Server-Side Sessions
5:05
Session IDs
6:26
Session IDs
6:27
The SID is Used by the Server to:
7:08
A Client Passes an SID to the Server with Each HTTP Request Via:
8:15
Sessions in PHP
12:19
Sessions in PHP
12:20
session_start()
14:40
session_start() Overview
14:41
Coding Example: Using session_start () to Continue a Session
18:03
$_SESSION Superglobal
22:06
$_SESSION Superglobal Overview
22:07
Coding Example: Setting a Session Variable via $_SESSION
25:22
Accessing Session Data
28:08
Accessing Session Data
28:09
Deleting Session Data
31:43
Deleting Session Data
31:44
Coding Example: Deleting Session Data
32:16
Configuring PHP Sessions
36:14
session.cookie_lifetime, session.cookie_domain, and session.cookie_path
36:15
Coding Example: Configuring PHP Sessions
37:28
Configuring PHP Sessions (cont.)
40:56
session.use_cookies, session.use_trans_sid, and session.use_only_cookies
40:57
Coding Example: Configuring PHP Sessions
42:25
Homework Challenge
42:55
Homework Challenge: 1 - 5
42:56
Homework Challenge (cont.)
44:10
Homework Challenge: 6 - 10
44:11
Homework Challenge (cont.)
45:27
Homework Challenge: 11 - 13
45:28
Web Application Development

11m

Intro
0:00
Version 12.0 Overview
0:12
Version 12.0 Changes Part I: Updating 'viewCart.php' & 'checkout.php'
0:13
Version 12.0 Changes Part II
5:03
Destroying Sessions

29m 59s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Destroying Sessions
1:02
Destroying Sessions
1:03
session_destroy()
2:10
session_destroy() Overview
2:11
Coding Example: Setting a Session Variable and Destroying a Session
3:18
Deleting Session Cookies
8:38
Deleting Session Cookies
8:39
Coding example: Deleting Session Cookies
9:17
Review of Steps
21:07
Review of Steps
21:08
Garbage Collection
21:50
Garbage Collection Overview
21:51
Coding Example: Garbage Collection
24:30
Homework Challenge
26:28
Homework Challenge: 1 - 4
26:29
Homework Challenge (cont.)
28:16
Homework Challenge: 5 - 9
28:17
Web Application Development

19m 14s

Intro
0:00
Lesson Overview
0:13
Lesson Overview
0:14
_autoload()
0:46
Introduction to _autoload ()
0:47
Version 13.0 Overview
4:06
_autoload () and SessionManager Class
4:07
Updating 'viewCart.php' & 'checkout.php'
11:16
Introduction to Databases

21m 24s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
Flat Files
1:09
Flat Files: Definition and Example
1:10
Problems Associated with Using Flat Files as a Database
2:15
Relational Databases
3:29
Relational Databases
3:30
Relational Database Management System (RDBMS)
3:50
Tables
7:43
Tables
7:44
Columns
9:24
Columns
9:25
What is SQL?
10:45
Introduction to Structured Query Language
10:46
Standard Data Types of SQL
12:23
Primary Keys
13:19
Primary Keys
13:20
Primary Key Examples
16:36
Primary Key Examples
16:37
Introduction to MySQL

28m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
What is MySQL?
1:33
MySQL
1:34
MySQL Monitor
5:16
MySQL Monitor Overview
5:17
XAMPP & MySQL
5:58
In the MySQL Command: hostname, username and -p
7:05
Connecting to a MySQl Server
9:52
Connecting to a MySQl Server
9:53
Using MySQl Monitor
13:48
Using MySQl Monitor
13:49
GRANT Command
15:10
GRANT SQL Command
15:11
Privileges & Objects
18:18
Username, Hostname, and Password
19:37
Specifying Objects
20:05
Creating a PHP User Account
21:41
Creating a PHP User Account Overview
21:42
Meaning of all & *.*
23:35
Example: Creating a PHP User Account
23:48
Required Homework
26:27
Required Homework: 1 - 5
26:28
Required Homework (cont.)
27:28
Required Homework: 6
27:29
Creating Databases & Tables

23m 1s

Intro
0:00
Lesson Overview
0:08
Lesson Overview
0:09
Creating a Database
1:40
Introduction to Creating a Database
1:41
Example: Creating a Database
3:33
CREATE TABLE Command
6:43
CREATE TABLE Command
6:44
Data Types
7:39
Numeric Data Types: INT, INT UNSIGNED, and DECIMAL
7:40
String Data Types: CHAR (M), VARCHAR (M), and TEXT
9:23
Colum Attributes
11:00
PRIMARY KEY Attribute
11:01
AUTO INCREMENT Attribute
11:35
Items Table
13:07
Items Table
13:08
Useful Commands
17:04
SHOW TABLES Command & DESCRIBE Utility Statement
17:05
Example: Creating an Items Table
17:58
Required Homework
20:51
Required Homework: 1 - 6
20:52
Required Homework (cont.)
21:55
Required Homework: 7 - 9
21:56
SQL Command: INSERT

27m 11s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
INSERT Command
1:20
SQL INSERT Command
1:21
Specifying Values
3:16
Columns with Numeric Data Types
3:17
Columns with String Data Types
3:34
Columns with AUTO INCREMENT
4:07
Inserting Items
5:21
Inserting Items
5:22
Example: Inserting Items
7:03
SQL Text Files
14:04
SQL Monitor Client
14:05
MySQL Monitor & the < Operator
15:15
Example
17:35
Required Homework
22:32
Required Homework: 1 - 6
22:33
Required Homework (cont.)
24:19
Required Homework: 7 - 10
24:20
SQL Command: SELECT

24m 57s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
SELECT Command
0:42
SELECT Command: Definition and Syntax
0:43
Results of a SELECT Query
1:53
To Specify the Retrieval of All Columns from a Table
3:06
Example: SELECT Command
4:18
WHERE Clause
7:11
WHERE Clause
7:12
A SELECT Query with WHERE Clause has the Following Syntax
8:10
A Where Condition can Contain both Logical and Comparison Operators
9:44
Literal Values
13:24
Literal Values
13:25
Example: Literal Values
14:18
ORDER BY Clause
15:31
ORDER BY Clause & SELECT Query
15:32
Ascending and Descending Order
17:30
An ORDER BY Clause can Specify Multiple Columns to Order the Rows by
18:01
Example: SELECT Query with WHERE and ORDER BY Clause
20:32
Homework Challenge
21:59
Homework Challenge
22:00
Homework Challenge (cont.)
23:54
Homework Challenge
23:55
Using PHP from MySQL

32m 43s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
PHP/MySQL Architecture
0:56
PHP/MySQL Architecture
0:57
MySQLi Extension
3:05
MySQLi Extension
3:06
Steps to Using MySQL from PHP
5:53
Four Steps to Using MySQL from PHP
5:54
Step # 3
7:18
Connecting to a Database
8:12
To Connect to a MySQL Database
8:13
To Test for Connection Errors
10:20
Running an SQL Statement
11:54
Running an SQL Statement
11:55
Example
13:30
Processing the Results
15:58
For non-SELECT Queries
15:59
MySQLi Object Property: affected_rows
16:19
For INSERT Statements on Tables with an AUTO_INCREMENT Column
18:07
Closing the Connection
19:45
Closing the Connection
19:46
Coding Example
21:24
Coding Example: Using MySQL from PHP
21:25
Homework Challenge
29:00
Homework Challenge: 1 - 4
29:01
Homework Challenge (cont.)
31:10
Homework Challenge: 5 - 9
31:11
Web Application Development

30m 30s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
sprintf()
1:28
sprintf() Overview
1:29
Example
1:56
INSERT Statements with sprintf()
5:15
INSERT Statements with sprintf()
5:16
Version 14.0 Overview
10:00
Version 14.0 Changes & Examples Part 1
10:01
Version 14.0 Changes & Examples Part 2
21:58
SELECT QUERIES from PHP

24m 22s

Intro
0:00
Lesson Overview
0:14
Lesson Overview
0:15
SELECT Queries
1:21
SELECT Queries
1:22
MySQLi_Result Class
3:17
MySQLi_Result Class: num_rows
3:18
MySQLi_Result Class: fetch_assoc ( ) and fetch_object ( )
3:59
fetch_assoc()
5:17
fetch_assoc() Overview
5:18
Coding Example: Using fetch_assoc()
9:00
stdClass Objects
12:46
stdClass Objects
12:47
fetch_object()
14:19
fetch_object() Overview
14:20
Coding Example: Using fetch_object()
16:45
Freeing Result Set Memory
18:42
Freeing Result Set Memory
18:43
Coding Example: Using free ( )
20:01
Homework Challenge
22:07
Homework Challenge: 1 - 5
22:08
Web Application Development

17m 6s

Intro
0:00
Version 15.0 Overview
0:13
Version 15.0 Changes & Examples Part 1
0:14
Version 15.0 Changes & Examples Part 2
8:43
Linking Tables

24m 32s

Intro
0:00
Lesson Overview
0:16
Lesson Overview
0:17
A Departments Table
1:08
Departments Table
1:09
How Could We Model This in a Table: Option 1
1:26
How Could We Model This in a Table: Option 2
3:12
Database Normalization
4:37
Database Normalization
4:38
Foreign Keys
8:47
Foreign Keys
8:48
Linking Table
11:26
Linking Table
11:27
Multiple Column Primary Keys
15:30
Multiple Column Primary Keys
15:31
Example
18:51
Required Homework
22:34
Required Homework: 1 - 3
22:35
Required Homework (cont.)
24:10
Required Homework: 4
24:11
Web Application Development

24m

Intro
0:00
Version 16.0 Overview
0:11
Version 16.0 Changes
0:12
Version 16.0 Coding Examples
4:12
Version 16.0 (cont.)
18:30
Version 16.0 Changes & Examples Part 2
18:31
SQL Command: DELETE

10m 33s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
DELETE Statement
0:30
DELETE Statement & Its WHERE Clause
0:31
Delete All Rows From a Table
2:57
Using DELETE from PHP
4:04
Using DELETE from PHP Overview
4:05
Coding Example: Using DELETE from PHP
6:37
Homework Challenge
8:53
Homework Challenge: 1 - 4
8:54
Web Application Development

16m 2s

Intro
0:00
Version 17.0 Overview
0:11
Version 17.0 Changes
0:12
Version 17.0 Coding Example
2:51
Transactions
12:50
Database Transaction
12:51
Steps in Using Transactions
14:00
SQL Command: UPDATE

32m 14s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
UPDATE Statement
0:54
UPDATE Statement & Its WHERE Clause
0:55
Example: UPDATE Statement
3:32
Using UPDATE from PHP
5:21
Using UPDATE from PHP Overview
5:22
Coding Example: Using UPDATE from PHP
6:53
htmlspecialchars()
9:04
htmlspecialchars()
9:05
Encoding Special Characters
9:23
Coding Example: htmlspecialchars()
13:41
addslashes()
20:40
addslashes()
20:41
Coding Example: addslashes()
22:52
Homework Challenge
27:55
Homework Challenge: 1 - 2
27:56
Homework Challenge (cont.)
30:14
Homework Challenge: 3 - 5
30:15
Homework Challenge (cont.)
30:41
Homework Challenge: 6 - 9
30:42
Web Application Development

12m 33s

Intro
0:00
Version 18.0 Overview
0:12
Version 18.0 Changes
0:13
Version 18.0 Coding Example
1:24
SQL: Joins

42m 16s

Intro
0:00
Lesson Overview
0:11
Lesson Overview
0:12
DATETIME Data Type
1:52
DATETIME Data Type
1:53
Modeling Orders
5:12
Modeling Orders
5:13
Customers Table
10:46
Customers Table
10:47
Example
16:18
Example: Order Table in MySQL
16:19
Joins
22:26
Joins Overview
22:27
Inner Join
23:09
Example: Joins
24:11
Join Conditions
28:14
Join Conditions
28:15
Example
28:32
Join Queries
30:00
Example: Join Conditions in MySQL
30:36
Implicit Joins
34:42
Implicit Joins
34:43
Example: Implicit Joins
35:57
Aliases
37:28
Introduction to Aliases
37:29
Example: Aliases
38:55
Required Homework
40:32
Problem 1
40:33
Problem 2
41:01
Problem 3
41:17
Web Application Development

29m 34s

Intro
0:00
Lesson Overview
0:12
Lesson Overview
0:13
Inserting Orders
0:44
Inserting Orders
0:45
Version 19.0 Overview
3:45
Version 19.0 Changes & Example Part 1
3:46
Version 19.0 Changes & Example Part 2
13:18
Version 19.1 Overview
21:10
Version 19.1 Changes
21:11
Version 19.1 Coding Example
22:18
User Authentication

26m 13s

Intro
0:00
Lesson Overview
0:10
Lesson Overview
0:11
User Authentication
1:31
User Authentication
1:32
Authentication with Sessions
2:34
Authentication with Sessions
2:35
Four Steps in Authentication via Sessions
2:50
Using Sessions to Restrict Access
3:58
Using Sessions to Restrict Access
3:59
Coding Example: Restricted Access Area
4:47
Authentication Methods
5:54
Authentication Methods Overview
5:55
Coding Example: Authentication Methods
7:31
Logging Out
9:57
Logging Out
9:58
Coding Example: Log Out
10:47
Users Table
13:50
Users Table
13:51
Example: Creating a Users Table
15:08
Password Hashing
17:30
Password Hashing
17:31
PHP and MySQL Built-in Hash Functions: sha1 ( ) and md5 ( )
18:43
Coding Example: Password Hashing
19:27
Required Homework
24:41
Required Homework: 1 - 4
24:42
Web Application Development

14m 36s

Intro
0:00
Version 20.0 Overview
0:13
Version 20.0 Changes & Examples Part 1
0:14
Version 20.0 Changes & Examples Part 2
5:05
Version 20.0 Changes & Examples Part 3
7:29
Version 20.0 (cont.)
8:31
Version 20.0 Changes & Examples Part 4
8:32
Loading...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Advanced PHP
Bookmark & Share Embed

Share this knowledge with your friends!

Copy & Paste this embed code into your website’s HTML

Please ensure that your website editor is in text mode when you paste the code.
(In Wordpress, the mode button is on the top right corner.)
  ×
  • - Allow users to view the embedded video in full-size.
Since this lesson is not free, only the preview will appear on your website.
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Services

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for Educator.com

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.
  • Learn at your own pace... anytime, anywhere!

Exceptions

  • A try block is a section of code enclosed in curly braces that allows what are known as exceptions to be ‘thrown’ when an error is detected.
  • An exception is an instance of the built-in PHP Exception class, and the throw keyword is used to signal that an error/exception has occurred.
  • When an exception is thrown, execution of code in the try block immediately halts. PHP then looks for a catch block, which is an error handling section of code enclosed in curly braces, immediately following the try block where the exception occurred. If a catch block is found, PHP will run any error handling code contained in the catch block.
  • try/catch blocks are declared using the try and catch keywords.
  • When an Exception object is 'caught' it is assigned to a variable that can be used to access the Exception object between the curly braces of the catch block.
  • The Exception class constructor can take as its first argument an error message to associate with the Exception object. This message can be accessed using the Exception class's instance method getMessage().
  • Once an exception is caught it can be ‘re-thrown’ out of the method it was caught in to be caught by a try/catch block in a calling method.
  • Additional Resources:

Exceptions

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Lesson Overview 0:12
    • Lesson Overview
  • try Blocks 0:44
    • try Blocks Definition
  • catch Blocks 2:03
    • catch Blocks: Definition and Syntax
    • Coding Example: try/catch Blocks
    • When an Exception Object is Caught & Error Handling
  • Exception Class 7:02
    • Exception Class
    • Coding Example: Using try/catch to Catch an Exception Thrown from a Method
  • Re-Throwing Exceptions 16:39
    • Re-Throwing Exceptions
    • Coding Example: Re-throwing an Exception
  • Homework Challenge 20:40
    • Homework Challenge: 1 - 5
  • Homework Challenge (cont.) 22:17
    • Homework Challenge: 6

Transcription: Exceptions

Hello again, and welcome back to Educator.com's Advanced PHP with MySQL course.0000

In today's lesson, we are going to be introducing the concept of exceptions, which is an object-oriented way of error handling.0005

We are going to introduce what are new structures within PHP code.0014

We are going to be introducing what are known as try/catch blocks.0018

And they are blocks that work in pairs to be able to handle errors in your code.0023

We are going to talk about a built-in class to PHP called the Exception class, which is used to encompass an error.0027

It is a class that essentially represents an error that has occurred.0034

And then, we are going to talk about a concept that will maybe be clearer as we go through it, known as re-throwing exceptions.0037

PHP provides a way to more gracefully handle errors.0046

Right now, the way we do it in code is: you can suppress the error, using the @ operator, and then maybe output a message on your own.0050

Or if you don't catch the error, PHP will just output a very terse, ugly error.0059

Well, what PHP does is provides a functionality called tri/catch blocks.0065

And what a tri block is: it is a section of code that you enclose within curly braces.0071

And when you encounter an error condition within your code (for example, you try to open a file, and you get an error),0079

instead of just outputting an error message there, what you can do is what is called throwing an exception.0085

And what it is, is signaling to the code that an error has occurred.0091

And what you do is use the keyword throw, and you pass it a new instance of the Exception class0096

(which you don't have to include the definition for in your PHP file--it is built into PHP),0105

which typically contains an error message that you are going to include.0110

And then, we are going to see in a second that there is a catch block associated with this that is able to handle these different errors.0114

Let's take a look at that.0122

When an exception is thrown--as soon as an exception is thrown (you encounter it; you throw an error), the code in that try block stops.0126

For example, we were executing some code along here in the try block.0132

We encountered an error, and we threw this exception; any code that was down here no longer gets executed.0136

Instead, what happens is: execution resumes down here to a catch block.0142

A catch block says, "If an Exception object that is of type exception has been thrown..."0147

And here we are throwing an object of type Exception.0153

And you can actually catch other types of exceptions, and that involves inheritance,0158

which is a little more advanced object-oriented concept that we are not getting into in this course.0161

What the catch block does is: you can assign it to catch different types of exceptions.0168

In this case, we are just going to have it catch the generic Exception class that is provided by PHP.0172

We have some code along here; an error occurred; we throw an exception and set the error message for this Exception object to error.0179

What is going to happen is: code is immediately going to stop.0188

Nothing around here is going to get executed; it is going to go to the test statement; it is going to test if the exception thrown's class type was Exception.0191

Because it was, this is going to match, so what it is going to do is assign it to a value E.0205

And then, it is going to execute a section of code.0210

What this gives you the opportunity to do is: when that error is thrown, you can catch it and perform whatever sort of error handling you want to do.0215

In this particular case, as we will learn about, you are just going to be outputting an error message.0223

Let's take a look at a basic try/catch block.0229

Here, we have just a regular section of PHP code with a try statement.0234

And actually, we are not even testing for an error; to demonstrate the concept, we are just throwing an exception.0239

We are throwing a new instance of the Exception class--we are not even passing it any parameters, which is something you can do.0244

We have an associated catch block with this try block that is going to say, "When an exception is thrown up here, go ahead and catch it."0252

"And then, execute the code within these curly braces."0259

In this case, all we are going to do is output an error message that says an exception has been caught.0263

And because this throw always occurs, this is always going to execute; it is not conditional.0269

Typically, you would have some if statement that would say, "If this condition fails, then throw the exception."0274

In this particular example, we are just throwing it automatically to demonstrate.0279

Let's take a look at the example, and we can see that an exception has been caught.0285

What happened was: PHP ran this code; it got to this line; it says, "OK, this signals an error."0294

"I'm throwing an error; I'm stopping any code; and then, I go down here and process whatever error handling code is associated with that exception."0301

Now, one thing to notice is: let's say down here we had an echo statement, "Hello after."0309

I'm going to call it "Hello before"; so we have a statement before we throw the exception, and an echo statement afterwards.0317

Now, when you throw an exception, execution immediately stops in that code.0329

So, this line is not going to get executed; so if we go ahead and run this code, all we are going to see output is this Hello before, along with our exception here.0333

Let's put a break in there.0340

When we re-run our script, we are going to see Hello before, but we don't see Hello after.0344

And that is because, as soon as the throw occurs, execution of the statements in the try block stops.0349

And it is going to say an exception has been caught.0355

When an exception is caught, it is assigned to a variable that you can access within the curly braces.0362

We saw, in the last example, that it actually looks like this.0367

And here, you can define this in your code with whatever value you want.0380

What that says is, "This is going to catch any exceptions that are thrown within its associated try block,0383

and then it is going to assign the exception that it catches to this variable here that you declared."0390

In this case, we declared it e, so if we wanted to access the different properties and methods of this Exception object0395

(which we are going to talk about in a second), you would do it using this e method (for example, e-->getMessage, which gets its error message).0400

And so, in this catch blocks, this is typically where your error handling occurs and allows you to gracefully exit,0411

rather than having some terse PHP error statement going out to your users.0416

The Exception class has a constructor that can take up to three optional parameters,0425

the first of which is an error message to associate with the Exception object.0429

And then, there are a couple of different methods that the Exception class provides.0433

The first one we are going to talk about is getMessage, and what that one does is: if you set an error message0438

when you create the Exception object, when you pass the error message as the first parameter to the constructor,0443

when you call this getMessage on that instance (so within our catch block, if we called it on e, for example--0449

if that is the value we assign to the exception we are catching), if we call $e-->getMessage,0455

it is going to output whatever message we passed in the constructor to Exception, when we threw the exception.0463

There is also a getFile function that is an instance method of exception, so we would call it $e-->getFile.0469

And that outputs the file where the error occurred.0477

And then, they have this similar function getLine, which tells you the line where an error occurred.0480

If we take a look at an example called fileError.php, we are going to try to open a file called tmp.txt.0486

And it is a file that...let me just double-check to make sure that it...doesn't exist.0492

And the file doesn't exist; and when you try to open the file in read-only mode, it doesn't try to create the file if it doesn't exist.0500

So, when we try to open it, it is going to throw an error.0507

So, we have our error suppression operator here that is going to suppress the error.0509

And then, we can test open to see if an error occurred.0513

If it returns false, then that way we know that we had an error; so we are going to enter this if statement, this conditional statement.0516

And what we are going to say is that we are going to throw an exception.0523

We are going to throw a new exception that has an error message, "There was an error opening the file."0525

What is going to happen is: it is going to get caught as soon as this is thrown.0531

Execution of the code jumps down here to the catch statement.0536

It is going to catch the exception, because it is of the Exception class.0540

It is going to assign it to the variable e, and it is going to execute the code within these curly braces.0544

What we do here is: we are simply taking this exception object that was caught;0550

we are calling the instance method getMessage on it; we are outputting the message,0554

which is this error message we included in the constructor; and then, we are also making use of0560

the getLine and getFile instance methods of the Exception class to output where the line and the error occurred.0565

For example, if we go ahead and run this script, we are going to see that there was an error opening the file.0573

"Error occurred on line 27 of" and then it lists the name of the file where the error occurred.0586

And that, again, is because this file doesn't exist, and when you try to open something in read mode, it doesn't try and create the file.0591

So, it is going to generate an error.0598

Let's say, instead, we try to open it in overwrite mode, which automatically creates the file, if it doesn't exist.0599

Then, this isn't going to throw an error; and so now, when we run this file, we should see no output,0608

because open is going to be true, which is going to evaluate to false, so this exception will never get thrown.0612

And so, I will put a little output message here--"after if statement," let's say, so at least we have some output.0620

And that is going to show that this if statement doesn't get executed, and then we output this message.0632

Now, the other thing to note, as well, is: once you reach the end of the try block,0638

if you have not thrown any errors, you don't execute any of the code within the catch blocks.0642

What you would do at this point is: in this case, after we reach this echo statement down here,0647

no exception was thrown--we jump over any catch blocks associated with it, and we beginning executing the next line of code.0652

Maybe let's put another output statement here, "after catch block."0658

What we are going to see, when we run this script, is: open is not going to cause an error, so we are not going to throw an exception.0672

We are going to execute this next line in the try block.0678

Then, we are going to skip over the catch block, because an exception was not thrown.0682

And then, we are going to echo any statements after that.0686

In this case, it is going to say "after catch block."0689

So, when we re-run our script now, we are going to say "after if statement," "after catch block."0690

So, you can see that the exception was not thrown, because there wasn't an error anymore.0696

And then, you can see how the try block continues to execute after a throw statement, if the throw statement never gets executed;0702

and then also that, after you complete all of the statements in a try block, you simply jump down to here.0709

You notice that none of these lines got executed here; we didn't have anything that said an error occurred.0715

That is because an exception was not caught.0720

If you never throw an exception, the code in the catch blocks never gets executed.0724

One other example is: you can throw exceptions from methods, as well.0731

In our case, we have just been throwing them from a first-level PHP script.0742

Well, you can also do it, for example, from object methods.0748

Here is a stripped-down version of the DataFile class we have been using in our web application.0750

It has an access mode, a filename, and then a file handle.0755

You pass into the constructor the name of the file you want to open and the access mode you want to access it as.0759

And then, we define an open function; and the open function tests that the file name is valid, and it attempts to open the file.0765

If it does, it returns true, and the fileHandle property of this class gets set to the handle of the open file.0772

Now, if fopen returns an error, what we are going to do is set fileHandle to null, and we are going to use an exception.0783

And we are going to throw an exception that says there was an error opening the data file.0789

And so, what is going to happen is: when that gets thrown, there is no catch block here, so what it does is0794

jumps to the end of this method and throws the exception to wherever this function was called from.0802

So, if we have a script where we create a new DataFile object, and we try to open it,0807

and this open method is called within a try block, this open method (because it throws an exception that doesn't get caught)--0811

we are going to catch it; it is going to be caught here, because we have a catch block.0818

And then, we are going to be able to output the error message.0823

The other thing is: for example, let's say the filename is not a valid filename.0826

Well, that is also going to be an error; so down here, we can throw an exception with a different error message,0832

saying "instance variable filename needs to be set," because the filename wasn't properly set when creating this.0837

Here is a way that we can use this high-level script that calls this to be able to output two different error messages, depending on which exception occurs.0844

And we do that simply by setting a different value of the error message for our Exception object.0852

For example, if we try to open a data file, and we pass it the filename null, what is going to happen is:0859

when we try to open it, it is going to cause an error, because it is going to test if filename is not equal to null.0865

It is going to turn out false, and so what is going to happen is: it is going to execute this else statement, which is going to throw an exception.0871

If we go and run this script, we can see the error message: "in the open function of dataFile.php, the instance variable filename needs to be set."0878

This is a way you can provide useful information to maybe your users,0894

or also when you are debugging and things like that, to figure out where things are going wrong.0898

If we had just put 'error,' it is not as informative; so I always encourage you to, when you throw exceptions,0902

and you create error messages, make them as useful and as meaningful as possible, so you can really figure out what is going on.0908

Now, that is as opposed to...let's say, instead, that we pass it a valid filename, tmp.txt, that doesn't exist.0914

But we try to open it in read mode, and as we know, when we call open on a file in read mode that doesn't exist, it is going to throw an error.0929

So, our open method is going to enter this if statement, because the file is not equal to null.0935

But when it tries to open the file, it is going to throw an error.0941

So, what is going to happen is: this if statement is going to return false.0945

We are going to exit the else block, which throws this other exception that has a different error message0949

that says, "There was an error opening the file."0954

If we go back and save this, and we reload our script, we can see that we get a new error: "There was an error opening the data file."0958

That is how you can see how a method can throw an exception that you can catch outside of the class.0966

You don't actually have to catch it in whatever particular block it was defined in.0973

If an exception is thrown within a method, and there is no try/catch block, it will get thrown out to0977

wherever that method was called from--in this case, in our script, exceptionFromMethod.php.0984

And here, because we have a try/catch block associated with it, we are able to catch it, and then output the error message stored in the Exception object.0990

One thing that you can also do is re-throw exceptions.1001

That means that, if you catch an exception, instead of handling it and just outputting an error message, you can re-throw it.1004

We just learned that you can throw an exception within a method.1011

And if there is no catch block for it, it will be caught in whatever script called it, assuming there is a try/catch block there.1017

Well, what you can also do is: if you have a method that has a try/catch block in it, and it catches an exception,1023

it can throw the error again, which is going to throw it to whatever method caught that.1029

And then, in that case, what you are doing is: it is like this chain of throws, where you can pass it up to wherever you eventually want to handle it.1035

It is more easily understood if we look at an example.1042

Let's say we have this DataFile class that we have created a new function in.1046

It is the same as before, except we have created a new function called appendLine.1050

It is just to append a line to this data file.1054

In this appendLine function, the first thing we do is try to open the data file represented by this class; we call the object method open.1058

Well, we do this within a try block, because we know that this open method can throw an exception.1067

So, in our file, we are going to try to open this file that doesn't exist, so it is going to throw an error.1074

What is going to happen is: this is going to call this open; this open is going to throw an error.1087

Down here, we have a catch block that is going to catch the exception thrown by the open method.1094

And then, instead of outputting an error message here, it is going to re-throw that.1098

And simply, what it does is: you can say throw, and then you can pass it the object that represents that exception.1103

And then, what is going to happen is: whatever method called appendLine has the opportunity to catch that exception.1109

So, in our main script, what we do is declare a new DataFile object that is going to end up causing an error when we try to call appendLine.1116

And then, within a try block, we call the appendLine method with 'Hello, World!'1125

And so, what is going to happen is: we are going to call appendLine.1130

It is going to go into appendLine, and it is going to try to open the file, which is going to go up here.1135

It is going to encounter an error and throw an exception.1139

We are going to catch the exception here.1142

Instead of handling it here, within the object code, we want to handle it, for example, in our script,1144

because that is where we output things to the user.1149

We re-throw it; we have a try/catch block where we call this appendLine.1151

And so now, this exception that occurred two function calls deeper--we catch it in our main script, and then we can output the error message.1156

When we try to append this line, we are going to get the error message that says, in this case,1168

"The file could not be opened," because you can't open this file for reading, because it doesn't exist.1173

If we go and try to run this script, we can see that there is an error opening the data file.1179

We eventually called that method open by calling it from within appendLine, and open threw the exception1188

that appendLine caught, that re-threw it, that our main script caught, that was able to handle it.1197

And what this allows you to do is keep throwing errors down the chain of method calls,1201

until you get to a spot where you want to be able to handle it.1207

In this case, we didn't want to handle the error in this appendLine class, let's say,1209

because typically we want to keep our output separate from our programming logic.1216

So, instead of outputting HTML here in this appendLine function that said there was an error thrown,1222

we are just going to re-throw it up to our main script, which we use to output information to the user.1226

And then, we are going to output the error message there.1232

That is an example of what is known as re-throwing exceptions.1235

For the homework challenge, I want you to create a script that defines a function called divide--1241

just a regular function--not a class function or anything.1246

It takes two parameters that are numbers that are to be divided.1249

And what it is going to do is test if the divisor parameter (which we will have be the second parameter;1253

so the first parameter is going to be the dividend, and the second parameter is going to be the divisor) is equal to 0.1259

If it is equal to 0, I want you to throw an exception using that Exception class.1264

Throw a new exception, and then include an error message in the constructor of Exception that says, "Division by 0 was attempted."1269

That is if it is equal to 0; if the divisor is not equal to 0, then simply divide the dividend by the divisor and return the result.1277

In the same script, after you define the function (instead of defining it in a separate function library,1286

you can just define at the beginning of the script for this simple example), go ahead and call divide twice:1292

once with the numbers 10 and 5 (so that is going to try to divide 10 by 5).1298

And then, try to call it a second time with 1 and 0 (so it is going to try to divide 1 by 0, which is going to throw an exception).1301

Call both these methods within a try block, and associate a catch block with that try block that will catch an exception.1309

And it is going to catch that divide by 0 exception.1317

And what it is going to do is assign it to a variable, maybe $e.1320

And then, I want you to output the message that is associated with that exception.1325

And that message that is going to be associated with it is what you set when you throw the exception originally, when you call its constructor.1328

And then, when you run the script, you should verify that you see the output of 10 divided by 5 is going to equal 2.1338

And then, instead of seeing another output of 1 divided by 0, you should see your error handling code1343

that says, "An exception has occurred; you tried to divide by 0."1349

That will give you some experience with working with exception handling.1354

That ends today's lesson; thank you for watching Educator.com--I look forward to seeing you next time.1358

Educator®

Please sign in to participate in this lecture discussion.

Resetting Your Password?
OR

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Membership Overview

  • Available 24/7. Unlimited Access to Our Entire Library.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lecture slides for taking notes.
  • Track your course viewing progress.
  • Accessible anytime, anywhere with our Android and iOS apps.