Learn PHP in One Day and Learn It Well
PHP for Beginners with Hands-on Project
The only book you need to start coding in PHP immediately
By Jamie Chan
https://www.learncodingfast.com/php
Copyright 2020
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law.
Preface
This book is designed to help you learn PHP fast and learn it well. While the book is suitable for absolute beginners in PHP, you do need to be familiar with HTML and SQL (for Chapter 11).
The book covers a wide range of topics in PHP, carefully selected to give you broad exposure to the language. If you are an absolute beginner in PHP, you'll find that this book explains complex concepts in an easy to understand and concise manner.
At the end of the book, you'll be guided through a project that gives you a chance to put everything you've learned to use and see how it all ties together.
You can download the source code for the examples and project at
https://www.learncodingfast.com/php
Any errata can be found at
https://www.learncodingfast.com/errata
Contact Information
I would love to hear from you.
For feedback or queries, you can contact me at
.
More Books by Jamie
Learn SQL (using MySQL) in One Day and Learn It Well
Learn CSS (with HTML 5) in One Day and Learn It Well
Learn Python in One Day and Learn It Well (2nd Edition)
Learn Python in One Day and Learn It Well (Workbook)
Learn C# in One Day and Learn It Well
Learn Java in One Day and Learn It Well
Contents
Chapter 1: Introduction to PHP
Thank you for picking up this book. Im so glad you chose this book, and I sincerely hope the book can help you master PHP and introduce you to the world of dynamic web programming.
In this book, well be covering most of the major topics in PHP. These topics are carefully chosen to give you a broad exposure to PHP while not overwhelming you with unnecessary details. Well also be building a dynamic website together at the end of the book.
Excited?
Before we dive into PHP proper, note that this book requires you to have a basic understanding of HTML and MySQL.
If you are not familiar with these languages, you are encouraged to refer to my books Learn CSS (with HTML 5) in One Day and Learn It Well and Learn SQL (using MySQL) in One Day and Learn it Well.
If you are familiar, lets move on.
1.1 What is PHP?
PHP is a general-purpose programming language used mostly for web development. Created by Rasmus Lerdorf in 1994, it allows developers to create dynamic web pages with ease.
For instance, developers can create a form in HTML and process it using PHP. Depending on the inputs entered into the form, developers can use PHP to display different outputs to users.
Most of the time, PHP is used as a server-side language. This means that PHP code is not processed on the users computer (also known as a client).
In other words, when you access a PHP page on your browser, the code is not processed on your computer. Instead, your browser sends a request to a web server, which then processes the code and returns the result to the browser in the form of a web page.
More often than not, this web server is a remote computer where the PHP files are stored. For the web server to process PHP code, a special software known as the PHP interpreter needs to be installed.
Well learn to set up our web server and install the PHP interpreter using a free software called XAMPP in the next chapter.
1.2 Why Learn PHP?
There are many reasons for learning PHP.
Firstly, PHP is one of the most widely used web programming languages and is used in many popular content management systems such as Wordpress, Drupal and Joomla. As such, the demand for PHP programmers is high. If you plan on working as a freelance developer, PHP is an essential skill to have.
Next, PHP is designed to be beginner-friendly and easy to learn. In addition, due to the popularity of the language, if you run into any issues with your PHP code, you can find help easily. A simple search on the internet will likely help you resolve most of the problems you face.
Last but not least, the syntax of PHP is very similar to other programming languages such as Java or C. Once you are familiar with PHP, youll find it much easier to master other languages.
Ready to get started? Lets do it!
Chapter 2: Installing XAMPP
As mentioned in the previous chapter, well learn to set up our web server and install the PHP interpreter in this chapter. In addition, as well be using PHP to interact with a database later in this book, we need to set up our database server too.
To set up our web and database servers, we need to install three software: the Apache web server, the PHP interpreter and the MarieDB database server.
Installing all three software can be tedious if we do them one by one. Fortunately, some kind folks at Apache Friends created a free package that contains all the software we need. This package is known as XAMPP, which stands for Cross-platform (X), Apache web server (A), MarieDB database server (M), PHP (P) and Perl (P).
The MarieDB database server is a community-developed fork of the MySQL server. Although M in XAMPP officially stands for MarieDB, youll see that XAMPP labels the database server as MySQL in the software. Well follow this label and refer to the database server as MySQL in our book.
For detailed instructions on installing XAMPP and using it to set up our servers, check out https://learncodingfast.com/how-to-install-xampp-and-brackets.
Instructions are available on the accompanying site of this book so that whenever there are any changes to XAMPP, you can find the updated instructions on the site. This will ensure that youll always get the latest installation instructions.
Besides installing XAMPP, you are strongly encouraged to install an advanced text editor to do your coding in. While you can definitely code in a basic text editor (such as Notepad), an advanced text editor offers features like syntax highlighting that makes your code easier to read and debug.
A recommended free editor is Brackets. For instructions on installing Brackets, head over to https://learncodingfast.com/how-to-install-xampp-and-brackets as well.