The
PHP
Workshop

Built by a team of experts to help you unlock your next promotion, reboot your career, or kick off your latest side project.

Get Started Today

You'll be up and running with PHP in no time at all.

  • $29.99

    $29.99The PHP Workshop

    Unlock full, unlimited access and get started right away!
    Buy Now

Engineered for Success

Nobody likes going through hundreds of pages of dry theory, or struggling with uninteresting examples that don’t compile. We've got you covered. Any time, any device.

  • Learn by doing real-world development, supported by detailed step-by-step examples, screencasts and knowledge checks.

  • Become a verified practitioner, building your credentials by completing exercises, activities and assessment checks.

  • Manage your learning based on your personal schedule, with content structured to easily let you pause and progress at will.

Learn By Doing

You already know you want to learn PHP 7, and a smarter way to learn PHP development is to learn by doing.

The PHP Workshop focuses on building up your practical skills so that you can develop cutting-edge, high-performance web applications. It’s ideal if you’re looking to work with an existing application, or even develop your own side project with a PHP framework like Laravel. You'll learn from real examples that lead to real results.

On Your Terms

Build up and reinforce key skills in a way that feels rewarding.

You won't have to sit through any unnecessary theory. If you're short on time you can jump into a single exercise each day or spend an entire weekend learning about third-party libraries. It's your choice.

An Ideal Start

Fast-paced and direct, The PHP Workshop is the ideal companion for PHP beginners.

You'll build and iterate on your code like a software developer, learning along the way. This process means that you'll find that your new skills stick, embedded as best practice. A solid foundation for the years ahead.

Begin Your Journey

A simple, straightforward and pain-free way to learn PHP.

  • $29.99

    $29.99The PHP Workshop

    Unlock full, unlimited access and get started right away!
    Buy Now

Everything You Need

Every Workshop includes free access to a whole host of bonus downloadable content. No hidden fees or annoying DRM policies. Just pure, top-quality content.

  • Download a text-only version of the entire Workshop. Perfect for those moments where your WiFi connection is a bit spotty. Available as PDF or EPUB, and always DRM-free.

  • Save any of our step-by-step screencasts directly from our interactive player. You can rest easy knowing that you'll always have a live example to hand.

Get Build-Ready

Every Workshop includes a whole host of features that work together to help you get the job done. You’ll be ready to tackle real-world development in no time.
  • Hack Your Brain

    We've applied the latest pedagogical techniques to deliver a truly multimodal experience. It'll keep you engaged and make the learning stick. It's science!

  • Build Real Things

    Nobody likes wasting their time. We cut right to the action and get you building real skills that real, working developers value. The perfect approach for a career move.

  • Learn From Experts

    We've paired technical experts with top editorial talent. They've worked hard to deliver you the maximum impact for each minute you spend learning. It's our secret sauce.

  • Verify Your Credentials

    Prove yourself by taking the final challenge. We use the blockchain to cryptographically certify your newly vetted skill. It's perfect for sharing on social media. Hello LinkedIn!

  • Receive Free Updates

    Technology keeps changing, and so do we. We keep versions updated independently, so you'll always have access. No more worrying about third-party release cycles.

  • Access Anywhere

    All you need is an internet connection. We've built every course so that it works on desktop and mobile, giving you options that fit within your schedule.

What's Inside

From A to Z, we've got you covered!

  • 1. Introducing PHP

  • 2. Types and Operators

    • Overview
    • What are Data Types?
    • Exercise 2.1: Using Simple Data Types
    • Exercise 2.1: Using Simple Data Types
    • Arrays
    • Exercise 2.2: Creating a Multidimensional Array
    • Exercise 2.2: Creating a Multidimensional Array
    • Scalar Types
    • Exercise 2.3: Converting a Boolean to an Integer
    • Exercise 2.3: Converting a Boolean to an Integer
    • Exercise 2.4: Converting an Integer to a String
    • Exercise 2.4: Converting an Integer to a String
    • Exercise 2.5: Converting Centimeters to Meters
    • Exercise 2.5: Converting Centimeters to Meters
    • Operators and Expressions
    • Activity 2.1: Printing the BMI of a User
    • Summary
    • Quiz 2
  • 3. Control Statements

    • Overview
    • Boolean Expressions
    • Boolean Constants
    • Logical Operators
    • Branching
    • Exercise 3.1: Creating a Basic Script to Implement the if...else Test Case
    • Exercise 3.1: Creating a Basic Script to Implement the if...else Test Case
    • Exercise 3.2: Creating a Script to Implement a Nested if...else Structure
    • Exercise 3.2: Creating a Script to Implement a Nested if...else Structure
    • Ternary Operator
    • Exercise 3.3: Creating a Script Using the if... elseif... else Statement
    • Exercise 3.3: Creating a Script Using the if... elseif... else Statement
    • The switch Case
    • Exercise 3.4: Creating a Script to Implement a Switch Case
    • Exercise 3.4: Creating a Script to Implement a Switch Case
    • Looping
    • Exercise 3.5: Printing the Numbers 1 to 10 Using a while Loop
    • Exercise 3.5: Printing the Numbers 1 to 10 Using a while Loop
    • The do…while Loop
    • Exercise 3.6: Converting a while Loop to a do...while Loop
    • Exercise 3.6: Converting a while Loop to a do...while Loop
    • The for Loop
    • Exercise 3.7: Using a for Loop to Print the Days of the Week
    • Exercise 3.7: Using a for Loop to Print the Days of the Week
    • The foreach Loop
    • Exercise 3.8: Using a foreach Loop to Print the Days of the Week
    • Exercise 3.8: Using a foreach Loop to Print the Days of the Week
    • Nesting Loops
    • Exercise 3.9: Using Nested foreach Loops
    • Exercise 3.9: Using Nested foreach Loops
    • The break Statement
    • Exercise 3.10: Using a break Statement to Terminate a Loop's Execution
    • Exercise 3.10: Using a break Statement to Terminate a Loop's Execution
    • Exercise 3.11: Using continue to Skip an Item in a List
    • Exercise 3.11: Using continue to Skip an Item in a List
    • Alternative Control Syntaxes
    • Activity 3.1: Creating a Movie Listing Script to Print Movies per Director
    • Tips for Control Structures
    • Summary
    • Quiz 3
  • 4. Functions

    • Overview
    • What is a Callable?
    • Exercise 4.1: Using Built-in Functions
    • Exercise 4.1: Using Built-in Functions
    • Types of Callables
    • Language Constructs
    • Introduction to Built-In Functions
    • Exercise 4.2: Working with print_r()
    • Exercise 4.2: Working with print_r()
    • A Varying Number of Parameters
    • Exercise 4.3: Using Built-In Functions with Arrays
    • Exercise 4.3: Using Built-In Functions with Arrays
    • Introduction to User-Defined Functions
    • Exercise 4.4: Using the $GLOBALS array
    • Exercise 4.4: Using the $GLOBALS array
    • The Single Responsibility Principle
    • Exercise 4.5: Writing a Function that Adds Two Numbers
    • Exercise 4.5: Writing a Function that Adds Two Numbers
    • Variable Functions
    • Exercise 4.6: Working with Anonymous Functions
    • Exercise 4.6: Working with Anonymous Functions
    • Exercise 4.7: Creating Variable Functions
    • Exercise 4.7: Creating Variable Functions
    • Exercise 4.8: Playing with Functions
    • Exercise 4.8: Playing with Functions
    • Activity 4.1: Creating a Calculator
    • Summary
    • Quiz 4
  • 5. Object Oriented Programming

    • Overview
    • The Object Oriented Approach
    • Exercise 5.1: Using the Getter and Setter Methods
    • Exercise 5.1: Using the Getter and Setter Methods
    • Constructor
    • Exercise 5.2: Instantiating the Class and Printing the Details
    • Exercise 5.2: Instantiating the Class and Printing the Details
    • Inheritance
    • Exercise 5.3: Implementing Inheritance
    • Exercise 5.3: Implementing Inheritance
    • Access Modifiers
    • Exercise 5.4: Applying Access Modifiers
    • Exercise 5.4: Applying Access Modifiers
    • Static Fields and Methods
    • Exercise 5.5: Applying a Static Member
    • Exercise 5.5: Applying a Static Member
    • Class Abstraction
    • Exercise 5.6: Implementing an Abstract Class
    • Exercise 5.6: Implementing an Abstract Class
    • Interfaces
    • Exercise 5.7: Implementing an Interface
    • Exercise 5.7: Implementing an Interface
    • Abstract Classes versus Interfaces
    • Overriding
    • Exercise 5.8: Overriding an Inherited Method
    • Exercise 5.8: Overriding an Inherited Method
    • Overloading
    • Exercise 5.9: Implementing Attribute and Method Overloading
    • Exercise 5.9: Implementing Attribute and Method Overloading
    • Final Classes and Methods
    • Exercise 5.10: Implementing a Final Class and Methods
    • Exercise 5.10: Implementing a Final Class and Methods
    • Traits
    • Exercise 5.11: Implementing Trait
    • Exercise 5.11: Implementing Trait
    • Class Autoloading
    • Namespaces
    • Exercise 5.12: Implementing Namespaces
    • Exercise 5.12: Implementing Namespaces
    • Activity 5.1: Building a Student and Professor Object Relationship
    • Summary
    • Quiz 5
  • 6: Using HTTP

    • Overview
    • The Request-Response Cycle of a Web Application
    • Query Strings
    • Exercise 6.1: Dumping the $_SERVER Data
    • Exercise 6.1: Dumping the $_SERVER Data
    • $_COOKIE
    • Exercise 6.2: Setting and Reading a Cookie
    • Exercise 6.2: Setting and Reading a Cookie
    • Exercise 6.3: Writing and Reading Data from a Session
    • Exercise 6.3: Writing and Reading Data from a Session
    • Exercise 6.4: Using Query Strings in Web Pages
    • Exercise 6.4: Using Query Strings in Web Pages
    • Exercise 6.5: Sending and Reading POST Data
    • Exercise 6.5: Sending and Reading POST Data
    • Exercise 6.6: Uploading a File and Validating its Type
    • Exercise 6.6: Uploading a File and Validating its Type
    • Securing Input and Output Data
    • Exercise 6.7: Sanitizing and Validating the User Input
    • Exercise 6.7: Sanitizing and Validating the User Input
    • Escaping the Output
    • Exercise 6.8: Securing against XSS
    • Exercise 6.8: Securing against XSS
    • Cross-Site Request Forgery (CSRF)
    • Exercise 6.9: Securing against CSRF
    • Exercise 6.9: Securing against CSRF
    • Building an Application (Bootstrapping the Examples)
    • Exercise 6.10: Building an Application: The Home Page
    • Exercise 6.10: Building an Application: The Home Page
    • Exercise 6.11: Building an Application: The Profile Page and the Login Form
    • Exercise 6.11: Building an Application: The Profile Page and the Login Form
    • Activity 6.1: Creating a Support Contact Form
    • Summary
    • Quiz 6
  • 7. Data Persistence

    • Overview
    • File I/O Handling
    • Exercise 7.1: A Simple File Read (All at Once)
    • Exercise 7.1: A Simple File Read (All at Once)
    • Reading Files with the fread Function
    • Exercise 7.2: Reading Files with the fread Function
    • Exercise 7.2: Reading Files with the fread Function
    • Exercise 7.3: Benchmark File Reading
    • Exercise 7.3: Benchmark File Reading
    • Exercise 7.4: Reading Files Line by Line
    • Exercise 7.4: Reading Files Line by Line
    • Exercise 7.5: Reading CSV Files
    • Exercise 7.5: Reading CSV Files
    • Exercise 7.6: Downloading a File
    • Exercise 7.6: Downloading a File
    • Exercise 7.7: Writing to Files
    • Exercise 7.7: Writing to Files
    • Exercise 7.8: Appending Content in Files
    • Exercise 7.8: Appending Content in Files
    • Exercise 7.9: Deleting a File with PHP
    • Exercise 7.9: Deleting a File with PHP
    • Exercise 7.10: Creating Directories and Moving Files to the Archive
    • Exercise 7.10: Creating Directories and Moving Files to the Archive
    • Exercise 7.11: Copying Files
    • Exercise 7.11: Copying Files
    • Databases
    • Exercise 7.12: Connecting to MySQL
    • Exercise 7.12: Connecting to MySQL
    • Exercise 7.13: Creating a Database
    • Exercise 7.13: Creating a Database
    • Creating a Table
    • Exercise 7.14: Creating the Table
    • Exercise 7.14: Creating the Table
    • Exercise 7.15: Inserting Data into a Table
    • Exercise 7.15: Inserting Data into a Table
    • SQL Injection
    • Exercise 7.16: Inserting Data Using Prepared Statements
    • Exercise 7.16: Inserting Data Using Prepared Statements
    • Fetching Data from MySQL
    • Exercise 7.17: Fetching Data from MySQL
    • Exercise 7.17: Fetching Data from MySQL
    • Exercise 7.18: Updating Records in MySQL
    • Exercise 7.18: Updating Records in MySQL
    • Exercise 7.19: Deleting Records from MySQL
    • Exercise 7.19: Deleting Records from MySQL
    • The Singleton Pattern
    • Activity 7.1: Contact Management Application
    • Summary
    • Quiz 7
  • 8. Error Handling

    • Overview
    • Errors in PHP
    • Exercise 8.1: Using a Custom Error Handler
    • Exercise 8.1: Using a Custom Error Handler
    • Exercise 8.2: Logging with the Custom Error Handler
    • Exercise 8.2: Logging with the Custom Error Handler
    • Triggering a User-Level Error
    • Exercise 8.3: Triggering Errors
    • Exercise 8.3: Triggering Errors
    • Logging Errors at Script Shutdown
    • Exercise 8.4: Logging Fatal Errors at Shutdown
    • Exercise 8.4: Logging Fatal Errors at Shutdown
    • Exceptions
    • Exercise 8.5: Implementing Exceptions
    • Exercise 8.5: Implementing Exceptions
    • Exercise 8.6: Custom Exceptions
    • Exercise 8.6: Custom Exceptions
    • Custom Exception Handler
    • Exercise 8.7: Using a Custom Exception Handler
    • Exercise 8.7: Using a Custom Exception Handler
    • Translating Errors to Exceptions
    • Exercise 8.8: Translating Errors to Exceptions
    • Exercise 8.8: Translating Errors to Exceptions
    • Exercise 8.9: Simple Exception Handling
    • Exercise 8.9: Simple Exception Handling
    • Exercise 8.10: Better Usage of Exceptions
    • Exercise 8.10: Better Usage of Exceptions
    • Activity 8.1: Handling System and User-Level Errors
    • Summary
    • Quiz 8
  • 9: Composer

    • Overview
    • Exercise 9.1: Getting Started with Composer
    • Exercise 9.1: Getting Started with Composer
    • Exercise 9.2: Initializing a Project
    • Exercise 9.2: Initializing a Project
    • Exercise 9.3: Adding Dependencies
    • Exercise 9.3: Adding Dependencies
    • Semantic Versioning
    • Exercise 9.4: Applying Version Constraints
    • Exercise 9.4: Applying Version Constraints
    • Exercise 9.5: Re-Installing Vendor File
    • Exercise 9.5: Re-Installing Vendor File
    • Exercise 9.6: Installing Development Dependencies
    • Exercise 9.6: Installing Development Dependencies
    • Packagist
    • Exercise 9.7: Discovering Packages on Packagist.org
    • Exercise 9.7: Discovering Packages on Packagist.org
    • Namespaces
    • Exercise 9.8: Using PSR-4 to Load Classes
    • Exercise 9.8: Using PSR-4 to Load Classes
    • Exercise 9.9: Implementing Monolog
    • Exercise 9.9: Implementing Monolog
    • Activity 9.1: Implementing a Package to Generate a UUID
    • Summary
    • Quiz 9
  • 10: Web Services

    • Overview
    • An Example Web Service
    • Exercise 10.1: JSON Encoding
    • Exercise 10.1: JSON Encoding
    • HTTP Headers
    • Exercise 10.2: Manual API Testing with Insomnia
    • Exercise 10.2: Manual API Testing with Insomnia
    • Exercise 10.3: Making a GET Request with Guzzle
    • Exercise 10.3: Making a GET Request with Guzzle
    • Exercise 10.4: Sending a POST Request with Headers
    • Exercise 10.4: Sending a POST Request with Headers
    • Activity 10.1: Making Your Own POST Request to httpbin.org
    • Summary
    • Quiz 10
  • Activity Solutions

    • Activity 1.1: Displaying Query Strings in the Browser
    • Activity 1.1: Displaying Query Strings in the Browser
    • Activity 2.1: Printing the BMI of a User
    • Activity 2.1: Printing the BMI of a User
    • Activity 3.1: Creating a Movie Listing Script to Print Movies per Director
    • Activity 3.1: Creating a Movie Listing Script to Print Movies per Director
    • Activity 4.1: Creating a Calculator
    • Activity 4.1: Creating a Calculator
    • Activity 5.1: Building a Student and Professor Object Relationship
    • Activity 5.1: Building a Student and Professor Object Relationship
    • Activity 6.1: Creating a Support Contact Form
    • Activity 6.1: Creating a Support Contact Form
    • Activity 7.1: Contact Management Application
    • Activity 7.1: Contact Management Application
    • Activity 8.1: Handling System and User-Level Errors
    • Activity 8.1: Handling System and User-Level Errors
    • Activity 9.1: Implementing a Package to Generate a UUID
    • Activity 9.1: Implementing a Package to Generate a UUID
    • Activity 10.1: Making Your Own POST Request to httpbin.org
    • Activity 10.1: Making Your Own POST Request to httpbin.org
  • Assessment Test

    • Assessment

Get Verified

Complete The PHP Workshop to unlock your secure credential.

We seal a record of your certification on the public Bitcoin blockchain. This verifies your achievement and lets employers authenticate your status with Packt. Our credentials are easy to share, and are ideal for displaying on your LinkedIn profile.
A copy of a certificate for The PHP Workshop

Take A Step Forward

There has never been a better time to start learning PHP.

  • $29.99

    $29.99The PHP Workshop

    Unlock full, unlimited access and get started right away!
    Buy Now

Already Know PHP?

Don't worry, we've got your back with other languages and frameworks too!

Show me my options!