0%

Book Description

Learn all the fundamentals of PHP with a book that blends theory with practice to build up the skills you need for modern web development.

Key Features

  • Brush up on basic PHP 7 syntax and work with variables, data types, arrays, and loops
  • Master advanced concepts like building your own frameworks and creating your own applications
  • Apply your newly learned PHP skills to a variety of real-life business scenarios

Book Description

PHP is the preferred server-side scripting language for tech giants such as Facebook, Wikipedia, and Tumblr despite full-stack JavaScript gaining popularity with upcoming developers. This is because PHP performs better when dealing with heavy computations on the back end. In this book, you'll learn everything you need to get up and running with the latest version of PHP, including package management with tools such as composer, secure database operations, and a whole host of other best practices that will help you stay a step ahead of traditional programmers.

What you will learn

  • Understand the fundamentals of PHP and work with classes and inheritance
  • Learn about database operations and package management with composer
  • Tackle common security concerns and pitfalls using authentication and validation
  • Build effective PHP applications and frameworks for your business needs

Who this book is for

If you're already familiar with another programming language and want to learn about the fundamentals of PHP programming, you'll find the flow of this book to be an ideal fit. Having a prior understanding of HTML, MySQL, CSS, and JavaScript will be beneficial, but is not mandatory.

Table of Contents

  1. Beginning PHP
    1. Table of Contents
    2. Beginning PHP
      1. Why Subscribe?
      2. PacktPub.com
    3. Contributors
      1. About the Author
      2. Packt Is Searching for Authors like You
    4. Preface
      1. What This Book Covers
      2. What You Need for This Book
        1. Hardware
        2. Software
      3. Who This Book Is For
      4. Conventions
      5. Installation and Setup
      6. Installing WAMP on Windows
      7. Installing LAMP in Linux
      8. Installing MAMP for MAC OS
      9. Downloading the Example Code
    5. 1. Getting Started with PHP
      1. The Basics
        1. Using PHP to Display "Hello World"
        2. Variables and Data Types
        3. Working with Variables
        4. Operators
          1. Comparison Operators
          2. Logical Operators
          3. Mathematical Operators
        5. Combining Variables and Operators
        6. Conditionals
          1. Working with Conditionals
        7. Activity: Building an Employee Salary Calculator
      2. Summary
    6. 2. Arrays and Loops
      1. Arrays
        1. Indexed Arrays
        2. Associative Arrays
        3. Working with Arrays
        4. Converting a String into an Array
        5. Merging an Array into a String
        6. Slicing Arrays
        7. Sorting an Array
        8. Multidimensional Arrays
        9. Including an Array of Hobbies in Our Existing Project
      2. Loops
        1. for Loop
        2. Combining Loops and Arrays
        3. while Loops
        4. Working with the while Function
        5. Do-While Loops
        6. Conversion of a while Loop to a do-while Loop
        7. foreach Loops
        8. Activity: Working with the foreach Loop
      3. Summary
    7. 3. Functions and Classes
      1. Functions
      2. Creating a Simple Function
      3. Classes
      4. Activity: Calculate the Monthly Pay of an Employee
      5. Summary
    8. 4. Data Operations
      1. Inputting and Outputting Data
        1. Building a Form for Our User List
        2. Connect to a Database
      2. MySQL Basics
        1. Create a Database Table
        2. Insert a Record into the Database
        3. Fetch a Single Row from a Database Table
        4. Fetch Multiple Rows from a Database Table
        5. Update a Record in a Database Table
        6. Delete a Record in a Database Table
        7. Creating an employee Table
        8. Adding Users to a Database
      3. Summary
    9. 5. Building a PHP Web Application
      1. Concepts of OOP in a Framework Environment
        1. Namespaces
        2. Namespace App, Controllers, and Use Statements
        3. Defining Classes and Objects Using Namespaces
        4. Methods
        5. Access Modifiers
      2. Structure of a Framework
        1. Activity: Adding Contacts to a Directory
      3. Summary
    10. 6. Building a PHP Framework
      1. Setting up a Project Development Environment
      2. Error Reporting Using Composer and Whoops
        1. Setting up Composer
      3. Activity: Using Composer to Install Dependencies
      4. Configuration Class, Default Classes, and Routing
        1. Loading a View File
        2. Manipulating the Output
          1. Base Controller, Default States, and Routing
          2. Setting up Base Controller, Default States, and Routing
        3. Activity: Exploring the Results
      5. Working with PDO
        1. Creating a Contact Controller and Viewing the Records
        2. Activity: Creating and Executing the Model
      6. Summary
    11. 7. Authentication and User Management
      1. Setting Up Paths and Inclusion of Bootstrap
        1. Setting up the Paths and Creating the Absolute Paths to the Files Directory
        2. Creating Layout Files
        3. Inclusion of Bootstrap
      2. Inclusion of Bootstrap and HTML Markup
      3. Adding Security to the Project
        1. Helpers
        2. Authentication
          1. Dashboard
          2. Login
          3. Password Hashing
      4. Implementing Validation in PHP
      5. Password Recovery
        1. Introduction to a Third-Party Dependency PHP Mailer
      6. Building a Password Reset Mechanism for Our Application
      7. Building CRUD for User Management
        1. CRUD
      8. Building CRUD for User Management
        1. Optional Activity
      9. Summary
    12. 8. Building a Contacts Management System
      1. Overview CMS
      2. CRUD, the Contact Application
      3. Inserting CRUD functionality in Our Contacts Application
        1. Activity: Executing our Application
      4. Comments, Joins, and Date Formatting
      5. Creating a View Page and Building the Comments System
        1. Activity: Loading the Application
      6. Summary
    13. Index