Leanpub Header

Skip to main content

PHP 7 from Scratch

A Streamlined Approach to Modern PHP Mastery

Time to start from scratch! In this book we skip old, useless or deprecated functions and will ignore jargon. If you ever wanted to learn PHP, then there is no need to search the web for guides and videos divided between countless websites with no thread to follow. Just sit back and relax while I help you along your path to PHP mastery.

Minimum price

$14.99

$24.99

You pay

$24.99

Author earns

$19.99
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
1,252
Readers
128
Pages
About

About

About the Book

Ever wanted to learn PHP? Then you probably ran into the most common problems along the way. Be it outdated learning resources, half-assed explanations or just simply no clear path to follow. Programming is hard enough on it's own so all of us would do better with a resource that is up to date and sticks to the point. Since we finally get a new major PHP release after a whole decade it is time to review the status quo. A lot has happened in the last 13 years and there was never a better time to write a book about it.

In this book you will learn PHP 7 completely from scratch. There is no PHP knowledge required to start reading. What you do require is a very basic knowledge of HTML (especially Forms) and maybe some CSS. All of PHP7's new features will be naturally included in your learning experience and everything will be done in the way it should be done in 2017. No old stuff, no unneeded fluff, in this book we learn only the important stuff!

Each Chapter in this book comes with a specific set of practical challenges in multiple difficulties and the solutions can be found either at the end of the book or in the included zip file. Some of these challenges will even require you to use Google to find the methods needed to complete them. This has the purpose of preparing you for your own development career after this book. Knowing how to find the answers you need is already half the battle!

The book also includes hands on practical exams between chapters. These practical exams include things like capturing form data or creating a simple shopping cart and they will show you first hand how your knowledge is used in the real world. The best way to learn programming is by doing and not by reading. This book takes good care of that!

A Quick list of what the finished book includes:

  • A complete guide for Mac OSX and Windows on how to start developing in a virtual environment with Homestead.
  • PHP7 from Hello World to OOP. Including all new features and a step by step approach to modern testable and maintainable code.
  • Testing with PHP Unit
  • Modern Design Patterns and how to use them
  • Lot's of hands on challenges and practical examples to deepen your knowledge.
  • My personal contact data in case you got questions or get stuck.
  • And much, much more!

Share this book

Author

About the Author

Thomas Pichler

Hi there!

I am a 34 year old PHP Developer living in Los Angeles and I am terrible at marketing myself! I started with PHP when I was 13 years old and I am now looking back on a 16 year long journey of learning and improving my skills. I have worked as a Webdev all over the world including Austria, Canada, USA and Hong Kong. Most of my time these days is spent with Laravel and of course watching Laracasts.

Contents

Table of Contents

Introduction

  1. Why Another PHP Book?
  2. Is This Book For Me?
  3. How to Consume This Book
  4. How this book is different
  5. Exercises
  6. Code Files
  7. Errata
  8. How to Get in Touch

Chapter 1: The Setup

  1. The Shortcut Route
  2. Setup for Mac
  3. Step 1: Installing Sublime
  4. Step 2: Installing Composer
  5. Step 3: Installing Laravel Homestead
  6. Installing Virtual Box
  7. Installing Vagrant
  8. Time for Homestead
  9. Step 4: Configuring Laravel Homestead
  10. Setup for Windows
  11. Step 1: Installing the required software
  12. Git
  13. Git Bash
  14. Vagrant
  15. Virtual Box
  16. Bitvise Tunnelier
  17. Step 2: Configuring The Environment
  18. The Vagrant Box
  19. Vagrant Plugins
  20. Installing Homestead
  21. Generating your SSH Keys
  22. Configuring Homestead
  23. Launching Homestead

Chapter 2: Hello World

  1. PHP Tags
  2. Comments
  3. echo
  4. The semicolon
  5. All together
  6. Challenges
  7. Easy
  8. Medium
  9. Hard

Chapter 3: Variables and Data Types

  1. The = Operator
  2. Data Type - String
  3. Data Type - Integer
  4. Data Type - Float
  5. Challenges
  6. Easy
  7. Medium
  8. Hard

Chapter 4: Arrays

  1. Data Type - Array
  2. The var_dump() function
  3. Challenges
  4. Easy
  5. Medium
  6. Hard

Practical Lesson I: Dynamic Content & Navigation

  1. An Overview
  2. The $_GET Array
  3. Chapter 5: How to work with Strings
  4. The . Operator
  5. Using Variables inside Strings
  6. The implode() function
  7. The explode() function
  8. The str_replace() function
  9. Challenges
  10. Easy
  11. Medium
  12. Hard

Practical Lesson II: Capturing Form Data

  1. The Project Details
  2. Setting up the structure
  3. Some Boilerplate
  4. Our Form
  5. The method Attribute
  6. The action Attribute
  7. The name Attribute
  8. Our Capture Script
  9. The most important Superglobals
  10. How it looks
  11. Time to wrap up

Chapter 6: Arithmetic Operators

  1. The + Operator
  2. The - Operator
  3. The * Operator
  4. The / Operator
  5. The % Operator
  6. The ** Operator
  7. Assignment Operators
  8. Quick Increments and Decrements
  9. Math and PHP
  10. Challenges
  11. Easy
  12. Medium
  13. Hard

Chapter 7 - Methods and Functions I

  1. What is a function
  2. The syntax of a function
  3. Is that all?
  4. Challenges
  5. Easy
  6. Medium
  7. Hard

Chapter 8: Control Structures & Comparison Operators I

  1. Data Type - Boolean
  2. if & else
  3. The == Operator (Equal)
  4. The != Operator (Not Equal)
  5. The > Operator (Greater than)
  6. The < Operator (Less than)
  7. The >= Operator (Greater than or equal to)
  8. The <= Operator (Less than or equal to)
  9. Challenges
  10. Easy
  11. Medium
  12. Hard
  13. Diabolic

Chapter 9: Control Structures & Comparison Operators II

  1. The difference between equal and identical
  2. The === Operator (Identical)
  3. The !== (Not Identical)
  4. The ! Operator (Negation)
  5. The && Operator (And)
  6. The || Operator (Or)
  7. The <=> Operator (Spaceship)
  8. The ?? Operator (Null Coalesce)
  9. elseif()
  10. Challenges
  11. Easy
  12. Medium
  13. Hard

Practical Lesson III: A simple Calculator

  1. The Project Details
  2. Setting up the structure
  3. Boilerplate as usual
  4. Our Form
  5. The Calculations
  6. Some simple validations
  7. is_numeric()
  8. Includes
  9. include();
  10. require();
  11. require_once();
  12. Time to put everything together
  13. Chapter 10: Sessions and Cookies
  14. session_start();
  15. The $_SESSION Superglobal
  16. session_unset();
  17. session_destroy();
  18. What are Cookies?
  19. Setting a Cookie
  20. The setcookie(); function
  21. The time(); function
  22. How to calculate seconds
  23. Creating a Cookie
  24. Using a Cookie
  25. Deleting a Cookie
  26. Challenges
  27. Easy
  28. Medium
  29. Hard
  30. login.php
  31. user.php
  32. logout.php

Chapter 11: Loops

  1. The foreach() loop
  2. The while() loop
  3. The do while() loop
  4. The for() loop
  5. The continue; command
  6. The break; command
  7. Challenges
  8. Easy
  9. Medium
  10. Hard
  11. Diabolic

Practical Lesson IV: Shopping Cart

  1. The Project Details
  2. Setting up the structure
  3. Starting with the Products
  4. Implementing the Session
  5. Creating our Functions
  6. addItem($id, $name, $price, $quantity)
  7. editItem($id, $quantity)
  8. removeItem($id);
  9. destroyCart();
  10. More Boilerplate
  11. Adding an Item to the Cart

Chapter 12 - Methods and Functions II

  1. Strict Arguments
  2. Return Type Declaration
  3. Optional Parameters
  4. Variable Arguments
  5. Variable Functions
  6. Closures
  7. Challenges
  8. Easy
  9. Medium
  10. Hard
  11. Diabolical

Solutions

  1. Chapter 2
  2. Easy
  3. Medium
  4. Hard
  5. Chapter 3
  6. Easy
  7. Medium
  8. Hard
  9. Chapter 4
  10. Easy
  11. Medium
  12. Hard
  13. Chapter 5
  14. Easy
  15. Medium
  16. Hard
  17. Chapter 6
  18. Easy
  19. Medium
  20. Hard
  21. Chapter 7
  22. Easy
  23. Medium
  24. Hard
  25. Chapter 8
  26. Easy
  27. Medium
  28. Hard
  29. Diabolic
  30. Chapter 9
  31. Easy
  32. Medium
  33. Hard
  34. Chapter 10
  35. Easy
  36. Medium
  37. Hard
  38. login.php
  39. user.php
  40. logout.php
  41. Chapter 11
  42. Easy
  43. Medium
  44. Hard
  45. With continue use
  46. Without continue use
  47. Diabolical
  48. Chapter 12

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub