My Account Log in

1 option

PHP 8 solutions : dynamic web design and development made easy / David Powers.

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Powers, David, author.
Language:
English
Subjects (All):
PHP (Computer program language).
Web sites--Design.
Web sites.
Physical Description:
1 online resource (571 pages)
Edition:
Fifth edition.
Place of Publication:
[California] : Apress, [2022]
Summary:
Make your websites more dynamic by adding a feedback form, creating a private area where members can upload images that are automatically resized, or storing all your content in a database. David Powers has updated his definitive book to incorporate the latest techniques and changes to PHP with the arrival of PHP 8. New features include named attributes, constructor property promotion, the stricter and more concise match expression, union types, and more.​ The problem is, you're not a programmer and the thought of writing code sends a chill up your spine. Or maybe you've dabbled a bit in PHP and MySQL, but you can't get past baby steps. If this describes you, then you've just found the right book. PHP powers four out of every five websites that use a server-side language. In combination with the MySQL database it's ideal for creating dynamic websites. PHP and MySQL are free, easy to use, and provided by many web hosting companies in their standard packages. This book also covers MariaDB, a seamless replacement for MySQL that has been adopted on many web servers. Unfortunately, most PHP books either expect you to be an expert already or force you to go through endless exercises of little practical value. In contrast, this book gives you real value right away through a series of practical examples that you can incorporate directly into your sites, optimizing performance and adding functionality such as file uploading, email feedback forms, image galleries, content management systems, and much more. Each solution is created with not only functionality in mind, but also visual design. But this book doesn't just provide a collection of ready-made scripts: each PHP solution builds on what's gone before, teaching you the basics of PHP and database design quickly and painlessly. You'll learn how to optimize your code using object-oriented programming (OOP) techniques. By the end of the book, you'll have the confidence to start writing your own scripts or-if you prefer to leave that task to others-to adapt existing scripts to your own requirements. Right from the start, you're shown how easy it is to protect your sites by adopting secure coding practices. What You Will Learn Design and build dynamic PHP-based web sites and applications Get started right away through practical examples that you can reuse Incorporate PHP 8 elements including named attributes, constructor property promotion, and union types.
Contents:
Intro
Table of Contents
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: What Is PHP 8?
How PHP Has Grown
How PHP Makes Pages Dynamic
Creating Pages That Think for Themselves
How Hard Is PHP to Use and Learn?
Can I Just Copy and Paste the Code?
How Safe Is PHP?
What's New in PHP 8?
What Software Do I Need to Write PHP?
What to Look for When Choosing a PHP Editor
So Let's Get On with It…
Chapter 2: Getting Ready to Work with PHP
Checking Whether Your Web Site Supports PHP
Deciding Where to Test Your Pages
What You Need for a Local Test Environment
Setting Up on Windows
Getting Windows to Display Filename Extensions
Choosing a Web Server
Installing an All-in-One Package on Windows
Setting Up on macOS
Installing MAMP
Testing and Configuring MAMP
Where to Locate Your PHP Files (Windows and Mac)
Checking Your PHP Settings
Displaying the Server Configuration with phpinfo()
Editing php.ini
What's Next?
Chapter 3: How to Write PHP Scripts
PHP: The Big Picture
Telling the Server to Process PHP
Embedding PHP in a Web Page
Storing PHP in an External File
Using Variables to Represent Changing Values
Naming Variables
Assigning Values to Variables
Ending Commands with a Semicolon
Commenting Scripts
Single-Line Comments
Multiline Comments
Using Arrays to Store Multiple Values
PHP's Built-In Superglobal Arrays
Understanding When to Use Quotes
Special Cases: True, False, and Null
Making Decisions
Making Comparisons
Using Indenting and Whitespace for Clarity
Using Loops for Repetitive Tasks
Using Functions for Preset Tasks
Displaying PHP Output
Using the Short Echo Tag
Joining Strings Together
Working with Numbers
Understanding PHP Error Messages.
Why Is My Page Blank?
PHP Quick Checklist
Chapter 4: PHP: A Quick Reference
Using PHP in an Existing Web Site
Data Types in PHP
Checking the Data Type of a Variable
Explicitly Changing a Variable's Data Type
Checking Whether a Variable Has Been Defined
Doing Calculations with PHP
Arithmetic Operators
Using the Increment and Decrement Operators
Determining the Order of Calculations
Combining Calculations and Assignment
Adding to an Existing String
All You Ever Wanted to Know About Quotes-and More
How PHP Treats Variables Inside Strings
Using Escape Sequences Inside Double Quotes
Embedding Associative Array Elements in a String
Avoiding the Need to Escape Quotes with Heredoc Syntax
Creating Arrays
Building an Indexed Array
Building an Associative Array
Creating an Empty Array
Multidimensional Arrays
Using print_r() to Inspect an Array
The Truth According to PHP
Explicit Boolean Values
Implicit Boolean ("Truthy" and "Falsy") Values
Making Decisions by Comparing Two Values
Testing More Than One Condition
Using the switch Statement for Decision Chains
Using a match Expression for Decision Chains
Using the Ternary Operator
Setting a Default Value with the Null Coalescing Operator
Executing Code Repeatedly with a Loop
Loops Using while and do . . . while
The Versatile for Loop
Looping Through Arrays and Objects with foreach
Breaking Out of a Loop
Modularizing Code with Functions
Passing Values to Functions
Setting Default Values for Arguments
Variable Scope: Functions as Black Boxes
Returning Values from Functions
Generators: A Special Type of Function That Keeps on Giving
Passing by Reference: Changing the Value of an Argument
Functions That Accept a Variable Number of Arguments.
Automatically Unpacking an Array Passed to a Function
Optionally Specifying Data Types
Specifying Multiple Data Types
Using Named Arguments
Where to Locate Custom-Built Functions
Creating Anonymous Functions
Using the Concise Anonymous Syntax of Arrow Functions
Understanding PHP Classes and Objects
Using PHP Built-In Classes
Building Custom Classes
Accessing Methods and Properties in a Class
Setting the Visibility of Class Methods, Properties, and Constants
Using Constructor Property Promotion
Declaring and Using Class Constants
Using a Namespace to Avoid Naming Conflicts
Importing a Namespaced Class
Handling Errors and Exceptions
Creating New Variables Dynamically
Now to the Solutions
Chapter 5: Lightening Your Workload with Includes
Including Code from External Files
Introducing the PHP Include Commands
Where PHP Looks for Include Files
PHP Solution 5-1: Moving the Menu and Footer to Include Files
Choosing the Right Filename Extension for Includes
PHP Solution 5-2: Testing the Security of Includes
PHP Solution 5-3: Automatically Indicating the Current Page
PHP Solution 5-4: Automating a Page's Title from Its Filename
PHP Solution 5-5: Handling Missing Variables
Creating Pages with Changing Content
PHP Solution 5-6: Automatically Updating a Copyright Notice
PHP Solution 5-7: Displaying a Random Image
PHP Solution 5-8: Adding a Caption to the Random Image
Preventing Errors with Include Files
Checking the Existence of Variables
Checking Whether a Function or Class Has Been Defined
Suppressing Error Messages on a Live Web Site
Using the Error Control Operator
Turning Off display_errors in the PHP Configuration
Turning Off display_errors in an Individual File
PHP Solution 5-9: Redirecting When an Include File Can't Be Found.
Why Can't I Use Site Root-Relative Links with PHP Includes?
Document-Relative Links
Links Relative to the Site Root
Links Inside Include Files
Choosing Where to Locate Your Include Files
Security Considerations with Includes
Adjusting Your include_path
Editing the include_path in php.ini or .user.ini
Using .htaccess to Change the include_path
Using set_include_path()
Nesting Include Files
Chapter Review
Chapter 6: Bringing Forms to Life
How PHP Gathers Information from a Form
Understanding the Difference Between post and get
Getting Form Data with PHP Superglobals
Processing and Validating User Input
Creating a Reusable Script
PHP Solution 6-1: Preventing Cross-Site Scripting in a Self-Processing Form
PHP Solution 6-2: Making Sure Required Fields Aren't Blank
Preserving User Input When a Form Is Incomplete
PHP Solution 6-3: Creating Sticky Form Fields
Filtering Out Potential Attacks
PHP Solution 6-4: Blocking Email Addresses That Contain Suspect Content
Sending Email
Using Additional Email Headers Safely
PHP Solution 6-5: Adding Headers and Automating the Reply Address
PHP Solution 6-6: Building the Message Body and Sending the Mail
Troubleshooting mail()
Handling Multiple-Choice Form Elements
PHP Solution 6-7: Handling Radio Button Groups
PHP Solution 6-8: Handling Check-Box Groups
PHP Solution 6-9: Using a Drop-Down Option Menu
PHP Solution 6-10: Handling a Multiple-Choice List
PHP Solution 6-11: Handling a Single Check Box
Chapter 7: Using PHP to Manage Files
Checking That PHP Can Open a File
Creating a Folder Outside the Server Root for Local Testing on Windows
Creating a Folder Outside the Server Root for Local Testing on macOS
Configuration Settings That Affect File Access
Reading and Writing to Files.
Reading Files in a Single Operation
PHP Solution 7-1: Getting the Contents of a Text File
Opening and Closing Files for Read/Write Operations
Reading a File with fopen()
PHP Solution 7-2: Extracting Data from a CSV File
Replacing Content with fopen()
Appending Content with fopen()
Locking a File Before Writing
Preventing Overwriting an Existing File
Combined Read/Write Operations with fopen()
Moving the Internal Pointer
Exploring the File System
Inspecting a Folder with scandir()
Inspecting the Contents of a Folder with FilesystemIterator
Restricting File Types with the RegexIterator
PHP Solution 7-3: Building a Drop-Down Menu of Files
PHP Solution 7-4: Creating a Generic File Selector
Accessing Remote Files
Consuming News and Other RSS Feeds
Using SimpleXML
PHP Solution 7-5: Consuming an RSS News Feed
Creating a Download Link
PHP Solution 7-6: Prompting a User to Download an Image
Chapter 8: Working with Arrays
Modifying Array Elements
PHP Solution 8-1: Modify Array Elements with a Loop
PHP Solution 8-2: Modify Array Elements with array_walk()
PHP Solution 8-3: Modify Array Elements with array_map()
Merging Arrays
Using the Array Union Operator
Using array_merge() and array_merge_recursive()
Merging Two Indexed Arrays into an Associative Array
Comparing Arrays
Removing Duplicate Elements
PHP Solution 8-4: Joining an Array with Commas
Sorting Arrays
PHP Solution 8-5: Custom Sorting with the Spaceship Operator
Complex Sorting with array_multisort()
PHP Solution 8-6: Sorting a Multidimensional Array with array_multisort()
PHP Solution 8-7: Finding All Permutations of an Array
Processing Array Data
PHP Solution 8-8: Building Nested Lists Automatically
PHP Solution 8-9: Extracting Data from JSON
Automatically Assigning Array Elements to Variables.
Notes:
Description based on print version record.
Includes index.
ISBN:
9781523150854
1523150858
9781484271414
1484271416
OCLC:
1283845741

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account