Muutke küpsiste eelistusi

PHP 8 Solutions: Dynamic Web Design and Development Made Easy 5th ed. [Pehme köide]

  • Formaat: Paperback / softback, 558 pages, kõrgus x laius: 254x178 mm, kaal: 1097 g, 259 Illustrations, black and white; XXV, 558 p. 259 illus., 1 Paperback / softback
  • Ilmumisaeg: 26-Oct-2021
  • Kirjastus: APress
  • ISBN-10: 1484271408
  • ISBN-13: 9781484271407
Teised raamatud teemal:
  • Pehme köide
  • Hind: 62,59 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Tavahind: 73,64 €
  • Säästad 15%
  • Raamatu kohalejõudmiseks kirjastusest kulub orienteeruvalt 2-4 nädalat
  • Kogus:
  • Lisa ostukorvi
  • Tasuta tarne
  • Tellimisaeg 2-4 nädalat
  • Lisa soovinimekirja
  • Formaat: Paperback / softback, 558 pages, kõrgus x laius: 254x178 mm, kaal: 1097 g, 259 Illustrations, black and white; XXV, 558 p. 259 illus., 1 Paperback / softback
  • Ilmumisaeg: 26-Oct-2021
  • Kirjastus: APress
  • ISBN-10: 1484271408
  • ISBN-13: 9781484271407
Teised raamatud teemal:
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 its ideal for creating dynamic websites. PHP and MySQL are free, easy to use, and provided by many web hosting companies in their standard packages. Thisbook 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. Youll 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 writingyour own scripts orif you prefer to leave that task to othersto 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 Understand the subtle, but important differences between switch and match Work with the latest PHP 8 techniques, innovations, and best practices

Who This Book Is For





Readers should ideally have some prior exposure to web development using PHP. 
About the Author vii
About the Technical Reviewer xix
Acknowledgments xxi
Introduction xxiii
Chapter 1 What Is PHP 8? 1(8)
How PHP Has Grown
2(1)
How PHP Makes Pages Dynamic
2(1)
Creating Pages That Think for Themselves
3(1)
How Hard Is PHP to Use and Learn?
3(2)
Can I Just Copy and Paste the Code?
4(1)
How Safe Is PHP?
5(1)
What's New in PHP 8?
5(1)
What Software Do I Need to Write PHP?
6(1)
What to Look for When Choosing a PHP Editor
6(1)
So Let's Get On with It
7(2)
Chapter 2 Getting Ready to Work with PHP 9(12)
Checking Whether Your Web Site Supports PHP
9(1)
Deciding Where to Test Your Pages
10(1)
What You Need for a Local Test Environment
10(1)
Setting Up on Windows
11(1)
Getting Windows to Display Filename Extensions
11(1)
Choosing a Web Server
11(1)
Installing an All-in-One Package on Windows
11(1)
Setting Up on macOS
11(3)
Installing MAMP
12(1)
Testing and Configuring MAMP
12(2)
Where to Locate Your PHP Files (Windows and Mac)
14(1)
Checking Your PHP Settings
15(4)
Displaying the Server Configuration with phpinfo()
15(2)
Editing php.ini
17(2)
What's Next?
19(2)
Chapter 3 How to Write PHP Scripts 21(20)
PHP: The Big Picture
21(17)
Telling the Server to Process PHP
22(1)
Embedding PHP in a Web Page
22(1)
Storing PHP in an External File
23(1)
Using Variables to Represent Changing Values
23(3)
Ending Commands with a Semicolon
26(1)
Commenting Scripts
26(1)
Using Arrays to Store Multiple Values
27(2)
PHP's Built-In Superglobal Arrays
29(1)
Understanding When to Use Quotes
29(3)
Making Decisions
32(1)
Making Comparisons
33(1)
Using Indenting and Whitespace for Clarity
34(1)
Using Loops for Repetitive Tasks
34(1)
Using Functions for Preset Tasks
34(1)
Displaying PHP Output
35(2)
Understanding PHP Error Messages
37(1)
PHP Quick Checklist
38(3)
Chapter 4 PHP: A Quick Reference 41(40)
Using PHP in an Existing Web Site
41(1)
Data Types in PHP
41(3)
Checking the Data Type of a Variable
43(1)
Explicitly Changing a Variable's Data Type
43(1)
Checking Whether a Variable Has Been Defined
44(1)
Doing Calculations with PHP
44(2)
Arithmetic Operators
44(1)
Using the Increment and Decrement Operators
45(1)
Determining the Order of Calculations
45(1)
Combining Calculations and Assignment
46(1)
Adding to an Existing String
46(1)
All You Ever Wanted to Know About Quotes-and More
47(4)
How PHP Treats Variables Inside Strings
47(1)
Using Escape Sequences Inside Double Quotes
47(1)
Embedding Associative Array Elements in a String
48(1)
Avoiding the Need to Escape Quotes with Heredoc Syntax
49(2)
Creating Arrays
51(3)
Building an Indexed Array
51(1)
Building an Associative Array
52(1)
Creating an Empty Array
52(1)
Multidimensional Arrays
53(1)
Using print_r() to Inspect an Array
53(1)
The Truth According to PHP
54(6)
Explicit Boolean Values
54(1)
Implicit Boolean ("Truthy" and "Falsy") Values
55(1)
Making Decisions by Comparing Two Values
55(1)
Testing More Than One Condition
56(1)
Using the switch Statement for Decision Chains
57(1)
Using a match Expression for Decision Chains
58(1)
Using the Ternary Operator
59(1)
Setting a Default Value with the Null Coalescing Operator
60(1)
Executing Code Repeatedly with a Loop
60(3)
Loops Using while and do...while
60(1)
The Versatile for Loop
61(1)
Looping Through Arrays and Objects with foreach
62(1)
Breaking Out of a Loop
63(1)
Modularizing Code with Functions
63(12)
Passing Values to Functions
64(1)
Setting Default Values for Arguments
65(1)
Variable Scope: Functions as Black Boxes
65(1)
Returning Values from Functions
66(1)
Generators: A Special Type of Function That Keeps on Giving
67(1)
Passing by Reference: Changing the Value of an Argument
68(1)
Functions That Accept a Variable Number of Arguments
68(1)
Automatically Unpacking an Array Passed to a Function
69(1)
Optionally Specifying Data Types
70(2)
Using Named Arguments
72(1)
Where to Locate Custom-Built Functions
73(1)
Creating Anonymous Functions
73(2)
Understanding PHP Classes and Objects
75(4)
Using PHP Built-In Classes
75(1)
Building Custom Classes
76(3)
Handling Errors and Exceptions
79(1)
Creating New Variables Dynamically
80(1)
Now to the Solutions
80(1)
Chapter 5 Lightening Your Workload with Includes 81(38)
Including Code from External Files
81(36)
Introducing the PHP Include Commands
82(1)
Where PHP Looks for Include Files
82(4)
Choosing the Right Filename Extension for Includes
86(12)
Creating Pages with Changing Content
98(9)
Preventing Errors with Include Files
107(1)
Suppressing Error Messages on a Live Web Site
108(5)
Why Can't I Use Site Root-Relative Links with PHP Includes?
113(1)
Choosing Where to Locate Your Include Files
114(1)
Security Considerations with Includes
114(1)
Adjusting Your include_path
115(2)
Review
117(2)
Chapter 6 Bringing Forms to Life 119(38)
How PHP Gathers Information from a Form
119(5)
Understanding the Difference Between post and get
121(3)
Getting Form Data with PHP Superglobals
124(1)
Processing and Validating User Input
124(13)
Creating a Reusable Script
125(7)
Preserving User Input When a Form Is Incomplete
132(3)
Filtering Out Potential Attacks
135(2)
Sending Email
137(9)
Using Additional Email Headers Safely
137(9)
Handling Multiple-Choice Form Elements
146(9)
PHP Solution 6-7: Handling Radio Button Groups
148(7)
Review
155(2)
Chapter 7 Using PHP to Manage Files 157(34)
Checking That PHP Can Open a File
157(3)
Creating a Folder Outside the Server Root for Local Testing on Windows
158(1)
Configuration Settings That Affect File Access
159(1)
Reading and Writing to Files
160(13)
Reading Files in a Single Operation
160(4)
Opening and Closing Files for Read/Write Operations
164(9)
Exploring the File System
173(9)
Inspecting a Folder with scandir0
174(1)
Inspecting the Contents of a Folder with Filesystemiterator
174(4)
Restricting File Types with the RegexIterator
178(4)
Accessing Remote Files
182(6)
Consuming News and Other RSS Feeds
183(1)
Using SimpleXML
184(4)
Creating a Download Link
188(2)
PHP Solution 7-6: Prompting a User to Download an Image
188(2)
Review
190(1)
Chapter 8 Working with Arrays 191(44)
Modifying Array Elements
191(8)
PHP Solution 8-1: Modify Array Elements with a Loop
192(2)
PHP Solution 8-2: Modify Array Elements with array_walk()
194(2)
PHP Solution 8-3: Modify Array Elements with array_map()
196(3)
Merging Arrays
199(10)
Using the Array Union Operator
199(2)
Using array_mergeO and array_merge_recursive0
201(2)
Merging Two Indexed Arrays into an Associative Array
203(1)
Comparing Arrays
204(1)
Removing Duplicate Elements
205(1)
PHP Solution 8-4: Joining an Array with Commas
206(3)
Sorting Arrays
209(10)
PHP Solution 8-5: Custom Sorting with the Spaceship Operator
211(2)
Complex Sorting with array_multisort0
213(2)
PHP Solution 8-6: Sorting a Multidimensional Array with array_multisorto
215(2)
PHP Solution 8-7: Finding All Permutations of an Array
217(2)
Processing Array Data
219(9)
PHP Solution 8-8: Building Nested Lists Automatically
219(4)
PHP Solution 8-9: Extracting Data from JSON
223(5)
Automatically Assigning Array Elements to Variables
228(4)
Using the extract° Function
228(1)
Using list°
229(1)
Using Array Shorthand Syntax for listo
229(1)
PHP Solution 8-10: Using a Generator to Process a CSV File
229(3)
Unpacking Arguments from an Array with the Splat Operator
232(2)
PHP Solution 8-11: Processing a CSV File with the Splat Operator
232(2)
Review
234(1)
Chapter 9 Uploading Files 235(34)
How PHP Handles File Uploads
235(5)
Checking Whether Your Server Supports Uploads
236(1)
Adding a File Upload Field to a Form
237(1)
Understanding the $_FILES Array
237(3)
Establishing an Upload Directory
240(1)
Uploading Files
240(4)
Moving the Temporary File to the Upload Folder
241(3)
Creating a PHP File Upload Class
244(16)
PHP Solution 9-2: Creating the Basic File Upload Class
244(6)
Checking Upload Errors
250(3)
Changing Protected Properties
253(7)
Uploading Multiple Files
260(6)
How the $_FILES Array Handles Multiple Files
260(6)
Using the Upload Class
266(1)
Points to Watch with File Uploads
266(1)
Review
267(2)
Chapter 10 Generating Thumbnail Images 269(24)
Checking Your Server's Capabilities
269(1)
Manipulating Images Dynamically
270(16)
Making a Smaller Copy of an Image
270(16)
Resizing an Image Automatically on Upload
286(6)
Extending a Class
287(4)
Using the ThumbnailUpload Class
291(1)
Review
292(1)
Chapter 11 Pages That Remember: Simple Login and Multipage Forms 293(38)
What Sessions Are and How They Work
293(5)
Creating PHP Sessions
296(1)
Creating and Destroying Session Variables
296(1)
Destroying a Session
297(1)
Regenerating the Session ID
297(1)
The "Headers Already Sent" Error
297(1)
Using Sessions to Restrict Access
298(23)
PHP Solution 11-1: A Simple Session Example
298(4)
Using File-Based Authentication
302(1)
Making Passwords Secure
302(19)
Setting a Time Limit on Sessions
321(3)
PHP Solution 11-8: Ending a Session After a Period of Inactivity
321(3)
Passing Information Through Multipage Forms
324(5)
PHP Solution 11-9: Using Sessions for a Multipage Form
324(5)
Review
329(2)
Chapter 12 Getting Started with a Database 331(26)
MySQL or MariaDB?
331(1)
How a Database Stores Information
332(3)
How Primary Keys Work
333(1)
Linking Tables with Primary and Foreign Keys
334(1)
Breaking Down Information into Small Chunks
334(1)
Checkpoints for Good Database Design
335(1)
Using a Graphical Interface
335(2)
Launching phpMyAdmin
336(1)
Setting Up the phpsols Database
337(17)
MySQL Naming Rules
337(1)
Using phpMyAdmin to Create a New Database
338(1)
Creating Database-Specific User Accounts
339(4)
Creating a Database Table
343(2)
Inserting Records into a Table
345(5)
Creating an SQL File for Backup and Data Transfer
350(4)
Choosing the Right Data Type in MySQL
354(2)
Storing Text
354(1)
Storing Numbers
355(1)
Storing Dates and Times
355(1)
Storing Predefined Lists
356(1)
Storing Binary Data
356(1)
Review
356(1)
Chapter 13 Connecting to a Database with PHP and SQL 357(38)
Checking Your Remote Server Setup
357(1)
How PHP Communicates with a Database
358(12)
Connecting with the MySQL Improved Extension
359(1)
Connecting with PDO
359(1)
PHP Solution 13-1: Making a Reusable Database Connector
360(3)
Sanitizing Text Results from a Database
363(1)
Querying the Database and Displaying the Results
363(7)
Using SQL to Interact with a Database
370(6)
Writing SQL Queries
370(2)
Refining the Data Retrieved by a SELECT Query
372(4)
Understanding the Danger of SQL Injection
376(5)
PHP Solution 13-6: Inserting an Integer from User Input into a Query
376(5)
Using Prepared Statements for User Input
381(12)
Embedding Variables in MySQLi Prepared Statements
381(5)
Embedding Variables in PDO Prepared Statements
386(7)
Review
393(2)
Chapter 14 Creating a Dynamic Photo Gallery 395(20)
Why Not Store Images in a Database?
396(1)
Planning the Gallery
396(2)
Converting the Gallery Elements to PHP
398(3)
PHP Solution 14-1: Displaying the First Image
398(3)
Building the Dynamic Elements
401(13)
Passing Information Through a Query String
401(4)
Creating a Multicolumn Table
405(2)
Paging Through a Long Set of Records
407(7)
Review
414(1)
Chapter 15 Managing Content 415(28)
Setting Up a Content Management System
415(22)
Creating the Blog Database Table
416(2)
Creating the Basic Insert and Update Forms
418(1)
Inserting New Records
419(4)
Linking to the Update and Delete Pages
423(4)
Updating Records
427(9)
Deleting Records
436(1)
Reviewing the Four Essential SQL Commands
437(4)
SELECT
438(2)
INSERT
440(1)
UPDATE
440(1)
DELETE
441(1)
Security and Error Messages
441(1)
Review
441(2)
Chapter 16 Formatting Text and Dates 443(36)
Displaying a Text Extract
443(8)
Extracting a Fixed Number of Characters
443(2)
Ending an Extract on a Complete Word
445(1)
Extracting the First Paragraph
446(1)
Displaying Paragraphs
446(2)
Extracting Complete Sentences
448(3)
Let's Make a Date
451(26)
How MySQL Handles Dates
452(4)
Inserting Dates into MySQL
456(5)
Working with Dates in PHP
461(16)
Review
477(2)
Chapter 17 Pulling Data from Multiple Tables 479(20)
Understanding Table Relationships
479(2)
Linking an Image to an Article
481(17)
Altering the Structure of an Existing Table
481(2)
Inserting a Foreign Key in a Table
483(6)
Selecting Records from Multiple Tables
489(6)
Finding Records That Don't Have a Matching Foreign Key
495(2)
Creating an Intelligent Link
497(1)
Review
498(1)
Chapter 18 Managing Multiple Database Tables 499(38)
Maintaining Referential Integrity
499(19)
Support for Transactions and Foreign-key Constraints
500(3)
Inserting Records into Multiple Tables
503(2)
Creating a Cross-reference Table
505(1)
Getting the Filename of an Uploaded Image
506(1)
Adapting the Insert Form to Deal with Multiple Tables
507(11)
Updating and Deleting Records in Multiple Tables
518(17)
Updating Records in a Cross-Reference Table
518(3)
Treating Multiple Queries as a Block in a Transaction
521(8)
Preserving Referential Integrity on Deletion
529(4)
Creating Delete Scripts with Foreign-Key Constraints
533(1)
Creating Delete Scripts Without Foreign-Key Constraints
534(1)
Review
535(2)
Chapter 19 Authenticating Users with a Database 537(14)
Choosing a Password Storage Method
537(1)
Using Password Hashing
538(8)
Creating a Table to Store Users' Details
538(1)
Registering New Users in the Database
538(8)
Using Secret-Key Encryption
546(4)
Creating the Table to Store Users' Details
546(1)
Registering New Users
546(2)
User Authentication with Two-Way Encryption
548(1)
Decrypting a Password
549(1)
Updating User Details
550(1)
Where Next?
550(1)
Index 551
David Powers is the author of more than 30 highly successful video training courses and books on PHP. He began his professional career as a radio and TV journalist for the BBC, spending a large part of it in Japan reporting on the rise and collapse of the bubble economy. His background of reporting on complex issues in plain, jargon-free language reveals itself in his writing about PHP and web development.  David first became involved with web development in the early 1990s as Editor of BBC Japanese TV. With no marketing budget, he developed a bilingual web site to promote the channel. After leaving the BBC, he went on to develop a bilingual online database for an international consultancy, as well as teaching web development courses at two universities in the UK. In addition to writing and creating video training courses, hes a Trustee of a charity in North London that provides educational facilities for retired people and those no longer in full-time employment.