Be taught the basics of PHP on this free PHP course. Observe alongside to study PHP and use it to jot down internet apps.
Observe Alongside, Be taught by Doing
I encourage you to observe alongside and to do precisely what I do on display screen. This fashion you study by doing.
To assist, the PHP course GitHub repo accommodates the supply for every train and pattern venture that was constructed all through the course.
To get observe alongside, you will want a replica 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 will study an important abilities writing apps for the online.
- variables and syntax
- methods to make your purposes extra clever by making selections from inside your code
- arrays and the looping over these arrays
- methods to write your individual capabilities
- how PHP treats the variables each inside and outdoors of these capabilities
- methods to get and deal with person enter from each HTTP GET and POST request
- parsing JSON
Later you’ll study methods to construct an internet based mostly glossary utility.
Additionally, you will study:
- methods to arrange your venture utilizing controllers and FUSE
- methods to learn from and write to recordsdata
- 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 a substitute of browser. Secondly PHP is used for server-side growth. So the very first thing you might want to do is about up an setting for PHP growth.
What does this imply? We first need to arrange our laptop to run as an internet server. And that is the way it will work: We make a request to an internet server, the online server executes the PHP after which it returns the ensuing HTML.
On this part you’ll study what instruments you might want to arrange your PHP setting. Additionally, you will study by doing. So cease the video as many occasions as you need as you observe alongside and set a PHP setting in your laptop.
2. The PHP Programming Language
Syntax and Variables
Each language has its personal syntax. On this lesson, you will study the PHP fundamentals, and I am going to present you methods to retailer knowledge in reminiscence by utilizing PHP variables.
Error Reporting
Error messages are vital to builders—they inform us why and the place one thing went flawed. By default, we can’t 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 Circumstances and Selections
Virtually each utility you write might want to make selections and reply to sure circumstances. We’ll take a look at PHP circumstances and selections 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
Arrays are an integral a part of any programming language. These are knowledge buildings that enable us to retailer a number of values inside a single variable. On this lesson, we’ll take 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
On this lesson we’ll take 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 needed to simply construct an inventory of my favourite objects, we are able to try this very simply with a loop.
PHP Capabilities
Capabilities are one of the vital vital elements of any programming language. They assist us keep away from code duplication by permitting us to run the identical set of directions time and again on totally different knowledge. In reality, all through this complete course we now have used capabilities in each lesson.
You will study:
- primary ideas of capabilities in PHP
- methods to outline your individual 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
We use variables to retailer knowledge in reminiscence. Easy, however there are some guidelines that you might want to perceive. We’ll focus on these guidelines on this lesson, and we’ll additionally take a look at a few totally different PHP variable varieties: PHP native variables and PHP international variables. Additionally, I am going to clarify default perform parameters.
Study:
- scope
- what’s an area variable
- what’s a worldwide variable
PHP Embrace and PHP Require
Functions require a variety of code, and we have to arrange our utility into totally different recordsdata to maintain issues manageable.
On this lesson, we’ll take a look at methods to use a number of recordsdata with PHP embody and PHP require.
3. Person Enter and Saving Knowledge in PHP
PHP Get Requests
Internet apps are totally different from conventional purposes as a result of customers enter knowledge by means of HTTP requests. On this a part of our PHP tutorial, I am going to present you methods to retrieve knowledge from HTTP GET requests.
PHP Submit Requests
We use PHP POST requests to submit delicate info or to vary the state of our utility. On this lesson, I am going to present you methods to use $_POST
to get knowledge from a POST request.
We typically must persist knowledge all through the lifespan of our utility. Periods make that doable, so we’ll write a easy (however practical) authentication system utilizing PHP classes.
4. The Internet Glossary Undertaking
Within the earlier classes we have targeted on particular person elements of PHP so you may study the way it works. Now it is time to put that principle to apply. We’ll get palms on and construct a enjoyable studying venture—a glossary of internet terminology.
Separating PHP Logic From Presentation
A properly organized venture is straightforward to develop. On this lesson we’ll study the group of a venture. We’ll give attention to separating considerations. This can be a idea that isn’t simply utilized in PHP, or internet growth, however growth normally. The concept is that you’ve got totally different parts inside your utility which might be accountable for doing one factor, and one factor solely.
Working With Recordsdata
Typically you might want to learn and write to recordsdata on the server laptop. On this lesson, I am going to present you a few of the capabilities we use to do this.
Parse JSON and Output Knowledge
JSON has develop into an integral a part of any internet utility. Each language now has built-in JSON functionality together with PHP.
On this lesson, you will 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
Our internet glossary is coming alongside. We’re displaying an inventory of phrases, however we want a web page to show the main points of particular person phrases. We would like customers to have the flexibility 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
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
Paths, particularly relative paths, might be arduous to work with in PHP apps. On this lesson, I am going to present you methods to discover the trail to the foundation of your utility. Alongside the best way, you will get snug working with PHP paths in addition to PHP relative paths.
Creating PHP Phrases
Modifying one thing is rather a lot like creating one thing… with some variations. Within the earlier lesson, you realized methods to create PHP phrases, and on this lesson, you will discover ways to edit PHP phrases. We’ll create the view and write the code for modifying and saving knowledge in our internet glossary app.
Modifying PHP Phrases
Modifying one thing is rather a lot like creating one thing… with some variations. Within the earlier lesson, you realized methods to create PHP phrases, and on this lesson, you will discover ways to edit PHP phrases. We’ll create the view and write the code for modifying and saving knowledge in our internet glossary app.
Deleting PHP Phrases
Typically you simply need to delete some knowledge. On this lesson, I am going to present you one of many methods we are able to deal with deleting PHP phrases and deleting knowledge in our utility.
5. Object-Oriented Programming
Intro to PHP Courses
Courses are a option to arrange our code and make it simpler to know. On this lesson you’ll study the fundamentals of PHP’s courses. We’ll begin by creating an object.
Making a Knowledge Supplier Class
We are able to use courses to group and encapsulate associated performance. On this lesson, we’ll convert our file capabilities right into a FileDataProvider
class. a 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
On this lesson, we’ll write a knowledge abstraction layer (DAL) to take a seat between our utility and our DataProvider
. This can give us much more flexibility whereas defending our knowledge entry code.
Inheritance
Object-oriented programming is all about code reuse, and we are able to reuse performance for related courses with inheritance. You will find out how on this lesson.
6. PHP and MySQL
Intro to MySQL
With regards to knowledge storage, not a lot can match the pace and energy of a database. On this lesson, I am going to provide you with a short overview of MySQL and phpMyAdmin. We’ll additionally create our database.
Connecting to the Database
On this lesson, you will discover ways to hook up with a database with PDO, and we’ll begin writing our MySqlDataProvider
class. We’ll discuss creating and studying knowledge.
By the top of this lesson you’ll perceive how you utilize a database and extra importantly the way you do 4 issues with a database: create, learn, replace, and delete—CRUD for brief.
Inserting Knowledge
We’d like some knowledge to work with. We are able to simply create pattern knowledge with phpMyAdmin, but it surely’s extra enjoyable if we write the code to insert knowledge into the database.
Studying Knowledge With SELECT
Now that we now have knowledge within the database, we have to learn it in order that we are able to show it within the browser. You will study the essential SELECT
assertion on this lesson.
Now we have realized methods to use insert, choose, replace, and delete instructions. You’ll now discover ways to use them inside PHP. You’ll study PDO (PHP Knowledge Objects) and methods to use PDO to problem queries with a view to begin getting knowledge from the database.
Utilizing Ready Statements
We have to get within the behavior of utilizing ready statements when mixing SQL with exterior knowledge. It would defend us from opening a big safety gap for SQL injection assaults in our utility. Use them. All the time.
Looking Knowledge
Trying to find info in a database is definitely simple to do. It isn’t Google-level looking out, but it surely’s helpful generally. I am going to present you the way on this lesson.
Modifying and Deleting Knowledge
A few of the best issues we are able to do with a database are modifying and deleting data. You will discover ways to do that with the UPDATE
and DELETE
instructions.
Refactoring the Code
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
PHP 8 provides a brand new function that allows you to add readability and adaptability to your perform calls. We’ll take a look at named arguments on this lesson.
Selling Class Properties
The brand new property promotion function in PHP 8 makes it simpler to create and assign values to a category’s properties. You will discover ways to use it on this lesson.
Simplifying String Capabilities
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 allow you to study extra PHP string tips.
Conclusion
We lined rather a lot 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 person enter from PHP GET and POST requests, in addition to methods to use the session to persist knowledge between totally different pages. Not solely that, however we carried out an actual internet app utilizing these easy PHP abilities!