Be taught the basics of PHP on this free PHP course. Comply with alongside to study PHP and use it to jot down internet apps.
Comply with Alongside, Be taught by Doing
I encourage you to comply with alongside and to do precisely what I do on display. This fashion you study by doing.
To assist, the PHP course GitHub repo accommodates the supply for every train and pattern undertaking that was constructed all through the course.
To comply with alongside, you may want a duplicate of MAMP (macOS) or XAMPP (for Home windows and Linux). Obtain them right here:
What You Will Be taught in This Free PHP Course
On this course, you may study a very powerful expertise for writing apps for the online:
- variables and syntax
- methods to make your purposes extra clever by making choices from inside your code
- arrays and looping over these arrays
- methods to write your personal capabilities
- how PHP treats the variables each inside and out of doors of these capabilities
- methods to get and deal with consumer enter from each HTTP GET and POST requests
- parsing JSON
Later, you’ll study methods to construct a web-based glossary utility.
Additionally, you will study:
- methods to arrange your undertaking utilizing controllers and FUSE
- methods to learn from and write to information
- methods to construct a easy authentication system
- methods to use a MySQL database
PHP is a server-side language. This implies it runs on a server as an alternative of within the browser. Secondly, PHP is used for server-side growth. So the very first thing it is advisable to do is ready up an surroundings for PHP growth.
What does this imply? We first must arrange our pc to run as an online server. And that is the way it will work: We make a request to an online server, the online server executes the PHP, after which it returns the ensuing HTML.
On this part, you’ll study what instruments it is advisable to arrange your PHP surroundings. Additionally, you will study by doing. So cease the video as many occasions as you need as you comply with alongside and arrange a PHP surroundings in your pc.
2. The PHP Programming Language
Syntax and Variables
Each language has its personal syntax. On this lesson, you may study the PHP fundamentals, and I am going to present you methods to retailer information in reminiscence by utilizing PHP variables.
Error Reporting
Error messages are necessary to builders—they inform us why and the place one thing went flawed. By default, we cannot see any PHP errors within the browser, so on this lesson we’ll modify our PHP configuration to show error info in a PHP error log.
PHP Situations and Choices
Nearly each utility you write might want to make choices and reply to sure situations. We’ll have a look at PHP situations and choices on this a part of our PHP tutorial.
Some belongings you’ll be launched to incorporate:
- what’s a situation in programming?
- conditional operators
-
if
andelse
statements
PHP Arrays
Watch video lesson [1:00:20] ↗
Arrays are an integral a part of any programming language. These are information constructions that enable us to retailer a number of values inside a single variable. On this lesson, we’ll have a look at conventional PHP arrays in addition to PHP associative arrays.
- what’s an array?
- methods to create an array
- associative arrays
PHP Loops
Watch video lesson [1:14:34] ↗
On this lesson, we’ll have a look at loops. Loops and arrays go hand in hand as a result of loops enable us to loop over an array and output every merchandise inside that array. So if we wished to simply construct an inventory of my favourite gadgets, we may try this very simply with a loop.
PHP Capabilities
Watch video lesson [1:32:09] ↗
Capabilities are some of the necessary components of any programming language. They assist us keep away from code duplication by permitting us to run the identical set of directions over and over on totally different information. The truth is, all through this whole course we’ve got used capabilities in each lesson.
You will study:
- primary ideas of capabilities in PHP
- methods to outline your personal capabilities in PHP
- returning values from a perform and performance parameters in PHP
- setting default argument values or passing an argument by reference
Native and World PHP Variables
Watch video lesson [1:41:24] ↗
We use variables to retailer information in reminiscence. Easy, however there are some guidelines that it is advisable to perceive. We’ll focus on these guidelines on this lesson, and we’ll additionally have a look at a few totally different PHP variable varieties: PHP native variables and PHP world variables. Additionally, I am going to clarify default perform parameters.
Study:
- scope
- what’s an area variable
- what’s a world variable
PHP Embrace and PHP Require
Watch video lesson [1:57:07] ↗
Functions require loads of code, and we have to arrange our utility into totally different information to maintain issues manageable. On this lesson, we’ll have a look at methods to use a number of information with PHP embody and PHP require.
3. Consumer Enter and Saving Knowledge in PHP
PHP Get Requests
Watch video lesson [2:09:00] ↗
Internet apps are totally different from conventional purposes as a result of customers enter information by way of HTTP requests. On this a part of our PHP tutorial, I am going to present you methods to retrieve information from HTTP GET requests.
PHP Publish Requests
Watch video lesson [2:25:07] ↗
We use PHP POST requests to submit delicate info or to alter the state of our utility. On this lesson, I am going to present you methods to use $_POST
to get information from a POST request.
We typically must persist information all through the lifespan of our utility. Periods make that potential, so we’ll write a easy (however purposeful) authentication system utilizing PHP classes.
4. The Internet Glossary Challenge
Within the earlier classes, we have targeted on particular person components of PHP so you’ll be able to study the way it works. Now it is time to put that concept to apply. We’ll get arms on and construct a enjoyable studying undertaking: a glossary of internet terminology.
Separating PHP Logic From Presentation
Watch video lesson [2:55:44] ↗
A well-organized undertaking is straightforward to develop. On this lesson, we’ll study the group of a undertaking. We’ll concentrate on separating considerations. It is a idea that isn’t simply utilized in PHP, or internet growth, however growth usually. The thought is that you’ve got totally different parts inside your utility which are liable for doing one factor, and one factor solely.
Working With Recordsdata
Watch video lesson [3:09:12] ↗
Generally it is advisable to learn and write to information on the server pc. On this lesson, I am going to present you a number of the capabilities we use to do this.
Parse JSON and Output Knowledge
Watch video lesson [3:23:29] ↗
JSON has turn into an integral a part of any internet utility. Each language now has built-in JSON functionality, together with PHP.
On this lesson, you may study:
- methods to change a string into JSON
- how one can work with JSON by parsing it into arrays and objects that we are able to then use in our utility
Including a Element Web page
Watch video lesson [3:38:26] ↗
Our internet glossary is coming alongside. We’re displaying an inventory of phrases, however we want a web page to show the small print of particular person phrases. We would like customers to have the power to click on on a time period and be taken to their definitions (for instance). That is what we’ll construct on this lesson.
Truthiness and Including a PHP Search
Watch video lesson [3:50:38] ↗
Looking is a typical function many apps require, so on this lesson we’ll implement a PHP search function for our internet glossary app. Alongside the best way, I am going to educate you about truthiness and falsiness in PHP.
Managing PHP Paths
Watch video lesson [4:07:53] ↗
Paths, particularly relative paths, could be onerous to work with in PHP apps. On this lesson, I am going to present you methods to discover the trail to the basis of your utility. Alongside the best way, you may get snug working with PHP paths in addition to PHP relative paths.
Creating PHP Phrases
Watch video lesson [4:18:20] ↗
We would like to have the ability to handle and replace the phrases in our internet glossary app. So on this lesson, you may learn to create new PHP phrases and retailer them within the PHP time period information file.
Enhancing PHP Phrases
Watch video lesson [4:32:45] ↗
Enhancing one thing is lots like creating one thing… with some variations. Within the earlier lesson, you realized methods to create PHP phrases, and on this lesson, you may learn to edit PHP phrases. We’ll create the view and write the code for enhancing and saving information in our internet glossary app.
Deleting PHP Phrases
Watch video lesson [4:32:45] ↗
Generally you simply must delete some information. On this lesson, I am going to present you one of many methods we are able to deal with deleting PHP phrases and deleting information in our utility.
5. Object-Oriented Programming
Intro to PHP Lessons
Watch video lesson [5:09:13] ↗
Lessons are a method to arrange our code and make it simpler to grasp. On this lesson, you’ll study the fundamentals of PHP courses. We’ll begin by creating an object.
Making a Knowledge Supplier Class
Watch video lesson [5:17:33] ↗
We will use courses to group and encapsulate associated performance. On this lesson, we’ll convert our file capabilities right into a FileDataProvider
PHP class. So we’ll reorganize our file code and make changes to our utility to make use of the supplier sample in object-oriented programming.
Writing a Knowledge Abstraction Layer
Watch video lesson [5:27:22] ↗
On this lesson, we’ll write a knowledge abstraction layer (DAL) to sit down between our utility and our DataProvider
. It will give us much more flexibility whereas defending our information entry code.
Inheritance
Watch video lesson [5:38:49] ↗
Object-oriented programming is all about code reuse, and we are able to reuse performance for related courses with inheritance. You will learn the way on this lesson.
6. PHP and MySQL
Intro to MySQL
Watch video lesson [5:50:54] ↗
In terms of information storage, not a lot can match the pace and energy of a database. On this lesson, I am going to offer you a quick overview of MySQL and phpMyAdmin. We’ll additionally create our database.
Connecting to the Database
Watch video lesson [6:00:30] ↗
On this lesson, you may learn to hook up with a database with PDO, and we’ll begin writing our MySqlDataProvider
class. We’ll discuss creating and studying information.
By the top of this lesson, you’ll perceive how you employ a database and extra importantly the way you do 4 issues with a database: create, learn, replace, and delete—CRUD for brief.
Inserting Knowledge
Watch video lesson [6:07:00] ↗
We’d like some information to work with. We will simply create pattern information with phpMyAdmin, but it surely’s extra enjoyable if we write the code to insert information into the database.
Studying Knowledge With SELECT
Now that we’ve got information within the database, we have to learn it in order that we are able to show it within the browser. You will study the fundamental SELECT
assertion on this lesson.
Now we have realized methods to use insert, choose, replace, and delete instructions. You’ll now learn to use them inside PHP. You’ll study PDO (PHP Knowledge Objects) and methods to use PDO to concern queries with a view to begin getting information from the database.
Utilizing Ready Statements
Watch video lesson [6:24:04] ↗
We have to get within the behavior of utilizing ready statements when mixing SQL with exterior information. It’s going to shield us from opening a big safety gap for SQL injection assaults in our utility. Use them. At all times.
Looking Knowledge
Watch video lesson [6:30:56] ↗
Trying to find info in a database is definitely simple to do. It is not Google-level looking out, but it surely’s helpful most often. I am going to present you ways on this lesson.
Enhancing and Deleting Knowledge
Watch video lesson [6:36:09] ↗
A number of the best issues we are able to do with a database are enhancing and deleting information. You will learn to do that with the UPDATE
and DELETE
instructions.
Refactoring the Code
Watch video lesson [6:41:32] ↗
Database code is repetitive. On this lesson, we’ll clear up the code so it is rather less repetitive.
7. New Options in PHP 8
Utilizing Named Arguments
Watch video lesson [6:51:27] ↗
PHP 8 gives a brand new function that allows you to add readability and suppleness to your perform calls. We’ll have a look at named arguments on this lesson.
Selling Class Properties
Watch video lesson [6:58:23] ↗
The brand new property promotion function in PHP 8 makes it simpler to create and assign values to a category’s properties. You will learn to use it on this lesson.
Simplifying String Capabilities
Watch video lesson [7:02:50] ↗
It is taken 20+ years, however PHP 8 lastly introduces simplified capabilities for testing strings and substrings. I could have an opinion or two on the topic…
The next tutorials will aid you study extra PHP string methods.
Conclusion
We lined lots on this PHP tutorial: from PHP variables and syntax to PHP arrays, loops, capabilities, and scope. You additionally realized methods to retrieve and deal with consumer enter from PHP GET and POST requests, in addition to methods to use the session to persist information between totally different pages. Not solely that, however we carried out an actual internet app utilizing these easy PHP expertise!