Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Kevin Tatroe, Peter MacIntyre

Rating No ratings yet

Why is PHP the most widely used programming language on the web? This updated edition teaches everything you need to know to create effective web applications using the latest features in PHP 7.4. You’ll start with the big picture and then dive into language syntax, programming techniques, and other details, using examples that illustrate both correct usage and common idioms. If you have a working knowledge of HTML, authors Kevin Tatroe and Peter MacIntyre provide many style tips and practical programming advice in a clear and concise manner to help you become a top-notch PHP programmer. • Understand what’s possible when you use PHP programs • Learn language fundamentals, including data types, variables, operators, and flow control statements • Explore functions, strings, arrays, and objects • Apply common web application techniques, such as form processing, data validation, session tracking, and cookies • Interact with relational databases like MySQL or NoSQL databases such as MongoDB • Generate dynamic images, create PDF files, and parse XML files • Learn secure scripts, error handling, performance tuning, and other advanced topics • Get a quick reference to PHP core functions and standard extensions

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 This is the definitive, practical guide to PHP 7.4 for anyone with basic HTML knowledge who wants to build dynamic, database-driven web applications, covering everything from language syntax to advanced topics like security and performance tuning. 【Book Arc】 - **Opening (~0%–9%)**: Introduces PHP's history, its role in web development, and the core language fundamentals—data types, variables, operators, and basic flow-control statements—establishing the syntax foundation for all subsequent chapters. - **Early (~9%–28%)**: Delves deeper into language mechanics, covering implicit casting, arithmetic and comparison operators, auto-increment/decrement, and the full suite of flow-control constructs (if, switch, while, for, foreach, try...catch, declare), plus how to embed PHP in HTML and include external code files. - **Early (~28%–38%)**: Focuses on functions—defining them, passing arguments, returning values (including by reference), and using variable functions—along with practical idioms for code organization and reuse. - **Middle (~38%–53%)**: Explores strings and arrays in depth, including concatenation, printf()/sscanf() formatting, string-searching functions, regular expressions (with greedy vs. nongreedy quantifiers), and array manipulation techniques for keys and values. - **Middle (~53%–End)**: Applies the fundamentals to real-world web scenarios, covering form processing, data validation, sessions, cookies, database interaction (MySQL and NoSQL), and advanced topics like secure scripting, error handling, and performance tuning. 【Key Takeaways】 - **PHP is a pragmatic, web-first language** (Opening): Its design prioritizes ease of embedding in HTML and rapid development over strict purity, making it accessible to beginners while powerful enough for complex applications. - **Master the operator zoo** (Early): Understanding the nuances of auto-increment/decrement (pre vs. post), comparison (including strict ===), and logical operators is critical for writing correct and efficient code, especially in loop conditions and validation logic. - **Flow control is the backbone of logic** (Early): The if/else, switch, while, for, and foreach constructs are the fundamental tools for building dynamic behavior, and knowing when to use each is a core skill. - **Functions promote reuse and clarity** (Early): Defining functions with clear inputs and outputs, and understanding the default copy-on-write behavior (making references rarely necessary), helps structure code for maintainability. - **Strings are the currency of web apps** (Middle): PHP's string functions—from concatenation to printf() formatting and searching—are highly optimized, and mastering them is essential for generating HTML, parsing input, and building URLs. - **Regular expressions require care** (Middle): Greedy quantifiers can cause unexpected matches; using nongreedy variants (e.g., *?) and understanding anchors like \A and \Z are key to reliable pattern matching. - **Security and performance are advanced but essential** (Late): The book covers secure script practices, error handling, and performance tuning, which are crucial for moving from toy examples to production-ready applications. 【Reading Tips】 - **Skim the history and setup chapters** (Opening): The early sections on PHP's origins are interesting but not critical; focus on the syntax examples and the sample database setup (library.sql) for hands-on practice. - **Deep-read the operator and flow-control chapters** (Early): These are dense with subtle details (e.g., string increment behavior) that will trip you up later; work through the tables and examples carefully. - **Practice the string and regex sections** (Middle): These are the most technical parts; write small test scripts to experiment with printf() formats and regex patterns rather than just reading them. - **Use the database chapter as a capstone project** (Late): The booklist.php example ties together HTML, PHP, and MySQL; modify it to test your understanding of sessions, validation, and error handling. - **Keep the quick reference handy**: The book includes a reference to core functions and extensions; use it as a lookup tool while coding rather than trying to memorize everything. 【Coverage Limits】 This guide synthesizes the provided excerpts, which cover the book's opening through the middle sections (up to arrays and regex). The later chapters on web techniques, databases, and advanced topics are mentioned in the blurb but not detailed in the excerpts.
Excerpt 1
24 Booleans 25 Arrays 26 Objects 27 Resources 28 Callbacks 29 NULL 29 Variables 30 Variable Variables 30 Variable References 30 Variable Scope 31 Garbage Col...
View in text
Excerpt 2
ut the following code sample as well as the related samples in Chapter 9. Example 1-4. Querying the books database (booklist.php) <?php $db = new mysqli("loc...
View in text
Excerpt 3
= 3) { for($i = 0; $i < 10; $i++) { // do something } } In this code, someFunction() is called after every third statement within the block is executed. You...
View in text
Excerpt 4
ue with === when testing for failure: if ($pos === false) { // wasn't found } else { // was found, $pos is offset into string } 104 | Chapter 4: Strings Anch...
View in text
Excerpt 5
exitFunction(); } 150 | Chapter 5: Arrays Declaring a Class To design your program or code library in an object-oriented fashion, you’ll need to define your...
View in text
Excerpt 6
file of valid users, or consult a Microsoft domain server. This example checks to make sure that the password is the username reversed (not the most secure a...
View in text
Excerpt 7
ases $black = imagecolorallocate($image, 0x00, 0x00, 0x00); imagefilledrectangle($image, 50, 50, 150, 150, $black); header("Content-Type: image/jpeg"); image...
View in text
Excerpt 8
R_NO_ELEMENTS XML_ERROR_INVALID_TOKEN 298 | Chapter 12: XML <url>http://example.org/article.php?id=20020430/458566</url> <time>2002-04-30 09:04:23</time> <au...
View in text
Tags
AI categories
Programming LanguageBackendWeb Technology
ISBN: 1492054135
Publisher: O′Reilly Media
Publish Year: 2020
Language: English
Pages: 545
File Format: PDF
File Size: 8.1 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…