Learn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5 Second Edition Steve Prettyman Download
Learn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5 Second Edition Steve Prettyman Download
https://textbookfull.com/product/learn-php-8-using-mysql-
javascript-css3-and-html5-second-edition-steve-prettyman/
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/
https://textbookfull.com/product/learning-php-mysql-javascript-
with-jquery-css-html5-5th-edition-robin-nixon/
https://textbookfull.com/product/learning-php-mysql-
javascript-6th-edition-robin-nixon/
https://textbookfull.com/product/pro-html5-games-learn-to-build-
your-own-games-using-html5-and-javascript-aditya-ravi-shankar/
New Perspectives on HTML5, CSS3, and JavaScript 6th
Edition Patric Carey
https://textbookfull.com/product/new-perspectives-on-
html5-css3-and-javascript-6th-edition-patric-carey/
https://textbookfull.com/product/learning-php-mysql-javascript-
early-release-6th-edition-robin-nixon/
https://textbookfull.com/product/murach-s-html5-and-css3-anne-
boehm/
https://textbookfull.com/product/beginning-iphone-and-ipad-web-
apps-scripting-with-html5-css3-and-javascript-1st-edition-apers-
chris-paterson-daniel/
https://textbookfull.com/product/responsive-web-design-by-
example-embrace-responsive-design-with-html5-css3-javascript-
jquery-and-bootstrap-4-hussain/
Learn PHP 8
Using MySQL, JavaScript, CSS3, and
HTML5
—
Second Edition
—
Steve Prettyman
Learn PHP 8
Using MySQL, JavaScript, CSS3,
and HTML5
Second Edition
Steve Prettyman
Learn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5
Steve Prettyman
Key West, FL, USA
Introduction�����������������������������������������������������������������������������������������������������������xvii
v
Table of Contents
Conditional Statements��������������������������������������������������������������������������������������������������������������� 98
Do It������������������������������������������������������������������������������������������������������������������������������������� 108
Functions���������������������������������������������������������������������������������������������������������������������������������� 109
Do It������������������������������������������������������������������������������������������������������������������������������������� 115
Arrays���������������������������������������������������������������������������������������������������������������������������������������� 116
Do It������������������������������������������������������������������������������������������������������������������������������������� 121
Chapter Terms��������������������������������������������������������������������������������������������������������������������������� 122
Chapter Questions and Projects������������������������������������������������������������������������������������������������ 123
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 419
x
About the Author
Steve Prettyman earned his bachelor of arts degree in education from Oglethorpe
University in 1979. He quickly began his teaching career as a high-school mathematics
instructor while continuing his education by earning a master’s degree in business
information systems from Georgia State University (1985). Since then, Steve has spent
over 30 years in the IT industry. He has also been a professor at Chattahoochee Technical
College, Kennesaw State University, and Southern Polytechnic State University for over
25 years. His primary teaching responsibilities include programming, web design, and
web application development. Steve, his wife Beverly, and their two dogs (Pixee and
Buster) currently reside in Paradise (Key West, Florida).
xi
About the Technical Reviewer
Satej Kumar Sahu works in the role of Senior Enterprise Architect at Honeywell. He is
passionate about technology, people, and nature. He believes through technology and
conscientious decision making, each of us has the power to make this world a better
place. In his free time, he can be seen reading books, playing basketball, and having fun
with friends and family.
xiii
Acknowledgments
Thank you to everyone who has helped put this book together. Special thanks to the
Introduction to PHP classes that have been the true testers and debuggers for this
journey.
Special acknowledgment to all the open source developers and providers of
free tutorials and training to every Internet user who wants to learn more about
programming.
xv
Introduction
Learn PHP 8: Using MySQL, JavaScript, CSS3, and HTML5 is intended for use as a
beginner- and intermediate-level programming book. It is not the goal of this book
to cover advanced techniques in the current versions of the PHP programming
language. Some knowledge of general programming concepts is expected, but no actual
programming experience or education is assumed.
All code examples in this book are compatible with PHP 8. Most examples are
compatible with PHP 7. The newest (as of the publication date) methods (functions)
available in PHP have been used to provide the reader with the most current coding
techniques. The examples use core methods provided in the PHP language. PHP
includes many additional methods to accomplish similar tasks. The reader may,
and should, research additional ways of improving security, performance, and other
techniques. It is the goal of this book to prompt users to always consider using the most
secure and efficient methods of program development. The code in this book provides
some examples of using these techniques. The user should remember that no program
is 100% secure. The programmer can only strive to make an application as secure as
possible. It takes a team of developers, network personnel, security administrators, data
center personnel, and others working together to provide the safest environment.
A Different Approach
There are quite a number of PHP books on the market today. What makes this book any
different than others?
• This book uses the concept of “learning by doing,” which shows the
reader how to develop applications with conditional statements,
loops, arrays, and methods. Over 70 PHP methods (functions) are
introduced and demonstrated in coding examples.
xvii
Introduction
• Object-oriented set methods are used to verify and filter user input.
Many other books simply show a set method accepting data and
storing it.
• The majority of the examples in the book are used to develop one
main application (ABC Canine Shelter Reservation System). As
the book progresses, the application is built from the beginning, in
stages, showing the reader that application development should be
broken into stages. Only after each stage is completed and tested
can the next stage begin. This approach works hand in hand with
multitier design. Additional programming exercises and a term
project are provided to enhance the understanding of development.
• The creation of user, change, and error logs are introduced. This
allows the reader to gain an understanding of how to provide backup
and recovery ability to keep an application functioning properly
when security breaches or exceptions occur.
• The introduction of data objects and the data tier demonstrates to the
reader the importance of creating an application that provides the
ability to change data storage techniques and data storage location
without requiring a major rewrite of the application. XML, JSON, and
MySQL examples are provided.
xviii
Introduction
• Throughout the book, web links are provided to point the user to
additional resources to help understand the material or to dig deeper
into the subject matter. Updates to link locations are provided on the
book’s web site.
C
hapter Overview
C
hapter 1: An Introduction to PHP 8
After completing this chapter, the student will be able to
C
hapter 2: Interfaces, Platforms, and Three-Tier
Programming
After completing this chapter, the student will be able to
C
hapter 3: The Basics: PHP 8 Syntax
After completing this chapter, the student will be able to
• Create a simple, error-free PHP program
• Understand the use and value of for, while, and foreach loops
xx
Introduction
C
hapter 4: Modular Programming
After completing this chapter, the student will be able to
• Import existing PHP code from another file or library into a program
C
hapter 5: Secured User Interfaces
After completing this chapter, the student will be able to
• Explain why user input must be filtered in the business rules tier
xxi
Introduction
C
hapter 6: Handling and Logging Exceptions
After completing this chapter, the student will be able to
• Create a PHP program that can create, raise, and handle user
exceptions
• Create a PHP program that uses the while loop and/or the for loop
C
hapter 7: Data Objects
After completing this chapter, the student will be able to
• Create a data class that inserts, updates, and deletes XML or JSON
data
• Explain how to create a data class that updates MySQL Data using a
SQL Script
• Create a PHP program that can recover data from a previous backup
xxii
Introduction
C
hapter 8: Authentication
After completing this chapter, the student will be able to
• Define sessions and explain how they are used for authentication
• Create a PHP program that will allow users to change their passwords
C
hapter 9: Multifunctional Interfaces
After completing this chapter, the student will be able to
xxiii
CHAPTER 1
An Introduction to PHP 8
PHP is a popular general-purpose scripting language that is especially
suited to web development. Fast, flexible, and pragmatic, PHP powers
everything from your blog to the most popular web sites in the world.
—www.php.net
1
© Steve Prettyman 2020
S. Prettyman, Learn PHP 8, https://doi.org/10.1007/978-1-4842-6240-5_1
Chapter 1 An Introduction to PHP 8
2
Chapter 1 An Introduction to PHP 8
PHP is an open source language. As such, each version of the language is created
using input from the individuals who use it—the programmers themselves. This allows
the language, over time, to evolve and float into the direction that is driven by the users.
From its first release in 1995 as a Personal Home Page Tool (PHP) by Rasmus Lerdorf, the
versions have been released on the Internet with forums to provide users the ability to
make suggestions and even provide code changes and additions. Today, www.php.net is
the official PHP web site.
The www.php.net home page provides information on each of the latest releases of
the language. It also provides information on future releases, the features planned for
those releases, and the planned release dates. In addition, other related PHP information
can be found, including links and information to major PHP conferences.
3
Chapter 1 An Introduction to PHP 8
The download page, as you might have guessed, provides the ability to gain easy
access to the latest versions of the language. However, as you will note, only the language
itself is provided. It is more common, and recommended, that the beginning user use
a WAMP (Windows, Apache, MySQL/MariaDB, PHP), LAMP (Linux, Apache, MySQL/
MariaDB, PHP), or MAMP (Mac, Apache, MySQL/MariaDB, PHP) stack package for initial
installation. These packages (which we will look at later) allow for easy installation of
multiple products at the same time. Otherwise, you have to run many separate installations.
4
Chapter 1 An Introduction to PHP 8
One of the more important pages of the PHP web site is the documentation page.
This page allows users to search for descriptions and functionality of the language itself.
You can also download the complete documentation. However, since this is a “live”
site, with possible changes occurring, the most current information is best obtained by
directly accessing it from the web site.
5
Chapter 1 An Introduction to PHP 8
You can use the manual as if it were a textbook by clicking through each link from
the beginning. The limited amount of explanation provided with each section of the
manual might cause a beginner to want to give up on programming and change interests
to something ghastly like networking! The manual does provide a great guide for
experienced programmers, as the syntax of the language is similar to other languages
such as Python, JavaScript, Perl, and Java.
On any page of the web site, the user can enter a term, an expression, or even a
function name to find more information. As the information is entered in search box, the
web page will provide the user with one or more options below the box for the user to
select.
6
Another Random Scribd Document
with Unrelated Content
Lexicon Homericum; composuerunt
F. Albracht [and others]
This book was produced in EPUB format by the Internet Archive.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com