Be taught the basics of PHP on this free PHP course. Observe alongside to study PHP and use it to put in writing net apps.
Observe Alongside, Be taught by Doing
I encourage you to observe alongside and to do precisely what I do on display. This fashion you study by doing.
To assist, the PHP course GitHub repo comprises the supply for every train and pattern undertaking that was constructed all through the course.
To get observe alongside, you may 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 may study crucial abilities writing apps for the online.Â
- variables and syntax
- how you can make your functions extra clever by making selections from inside your code
- arrays and the looping over these arrays
- how you can write your personal capabilities
- how PHP treats the variables each inside and out of doors of these capabilities
- how you can get and deal with person enter from each HTTP GET and POST request
- parsing JSON
Later you’ll study how you can construct an online based mostly glossary software.
Additionally, you will study:
- how you can manage your undertaking utilizing controllers and FUSE
- how you can learn from and write to information
- how you can construct a easy authentication system
- how you can use a MySQL database
PHP is a server-side language. This implies it runs on a server as an alternative of browser. Secondly PHP is used for server-side growth. So the very first thing it is advisable do is about up an atmosphere for PHP growth.Â
What does this imply? We first must arrange our laptop 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 arrange your PHP atmosphere. Additionally, you will study by doing. So cease the video as many occasions as you need as you observe alongside and set a PHP atmosphere in your laptop.Â
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 will present you how you can retailer knowledge in reminiscence through the use of PHP variables.
Error Reporting
Error messages are necessary to builders—they inform us why and the place one thing went unsuitable. 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 Choices
Nearly each software you write might want to make selections and reply to sure circumstances. We’ll have 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 have a look at conventional PHP arrays in addition to PHP associative arrays.
- what’s an array?
- how you can create an array
- associative arrays
PHP Loops
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 needed to simply construct an inventory of my favourite objects, we will do this very simply with a loop.
PHP Capabilities
Capabilities are probably the most necessary components 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 completely different knowledge. In truth, all through this complete course now we have used capabilities in each lesson.
You will study:
- fundamental ideas of capabilities in PHP
- how you can 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
We use variables to retailer knowledge in reminiscence. Easy, however there are some guidelines that it is advisable perceive. We’ll talk about these guidelines on this lesson, and we’ll additionally have a look at a few completely different PHP variable varieties: PHP native variables and PHP international variables. Additionally, I will clarify default perform parameters.
Study:
- scope
- what’s a neighborhood variable
- what’s a worldwide variable
PHP Embody and PHP Require
Purposes require numerous code, and we have to manage our software into completely different information to maintain issues manageable.
On this lesson, we’ll have a look at how you can use a number of information with PHP embody and PHP require.
3. Person Enter and Saving Information in PHP
PHP Get Requests
Net apps are completely different from conventional functions as a result of customers enter knowledge via HTTP requests. On this a part of our PHP tutorial, I will present you how you can 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 software. On this lesson, I will present you how you can use $_POST
to get knowledge from a POST request.
Â
We generally must persist knowledge all through the lifespan of our software. Classes make that attainable, so we’ll write a easy (however practical) authentication system utilizing PHP periods.
4. The Net 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 idea to apply. We’ll get arms on and construct a enjoyable studying undertaking—a glossary of net terminology.
Separating PHP Logic From Presentation
A effectively organized undertaking is simple to develop. On this lesson we’ll study the group of a undertaking. We’ll give attention to separating considerations. It is a idea that’s not simply utilized in PHP, or net growth, however growth on the whole. The thought is that you’ve got completely different elements inside your software which might be accountable for doing one factor, and one factor solely.
Working With Information
Typically it is advisable learn and write to information on the server laptop. On this lesson, I will present you among the capabilities we use to do this.
Parse JSON and Output Information
JSON has develop into an integral a part of any net software. Each language now has built-in JSON functionality together with PHP.Â
On this lesson, you may study:
- how you can change a string into JSON
- how one can work with JSON by parsing it into arrays and objects that we will then use in our software
Including a Element Web page
Our net glossary is coming alongside. We’re displaying an inventory of phrases, however we’d like a web page to show the main points of particular person phrases. We wish 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 out is a typical function many apps require, so on this lesson we’ll implement a PHP search function for our net glossary app. Alongside the way in which, I will train you about truthiness and falsiness in PHP.
Managing PHP Paths
Paths, particularly relative paths, will be onerous to work with in PHP apps. On this lesson, I will present you how you can discover the trail to the foundation of your software. Alongside the way in which, you may get snug working with PHP paths in addition to PHP relative paths.
Creating PHP Phrases
Modifying one thing is loads like creating one thing… with some variations. Within the earlier lesson, you discovered how you can create PHP phrases, and on this lesson, you may learn to edit PHP phrases. We’ll create the view and write the code for modifying and saving knowledge in our net glossary app.
Modifying PHP Phrases
Modifying one thing is loads like creating one thing… with some variations. Within the earlier lesson, you discovered how you can create PHP phrases, and on this lesson, you may learn to edit PHP phrases. We’ll create the view and write the code for modifying and saving knowledge in our net glossary app.
Deleting PHP Phrases
Typically you simply must delete some knowledge. On this lesson, I will present you one of many methods we will deal with deleting PHP phrases and deleting knowledge in our software.
5. Object-Oriented Programming
Intro to PHP Lessons
Lessons are a technique to manage our code and make it simpler to grasp. On this lesson you’ll study the fundamentals of PHP’s lessons. We’ll begin by creating an object.Â
Making a Information Supplier Class
We are able to use lessons 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 software to make use of the supplier sample in object-oriented programming.
Writing a Information Abstraction Layer
On this lesson, we’ll write an information abstraction layer (DAL) to sit down between our software and our DataProvider
. It will give us much more flexibility whereas defending our knowledge entry code.Â
Inheritance
Object-oriented programming is all about code reuse, and we will reuse performance for related lessons with inheritance. You will find out how on this lesson.
6. PHP and MySQL
Intro to MySQL
In relation to knowledge storage, not a lot can match the velocity and energy of a database. On this lesson, I will offer you a short overview of MySQL and phpMyAdmin. We’ll additionally create our database.
Connecting to the Database
On this lesson, you may learn to hook up with a database with PDO, and we’ll begin writing our MySqlDataProvider
class. We’ll speak about creating and studying knowledge.
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 Information
We’d like some knowledge to work with. We are able to simply create pattern knowledge with phpMyAdmin, however it’s extra enjoyable if we write the code to insert knowledge into the database.
Studying Information With SELECT
Now that now we have knowledge within the database, we have to learn it in order that we will show it within the browser. You will study the essential SELECT
assertion on this lesson.
We have now discovered how you can use insert, choose, replace, and delete instructions. You’ll now learn to use them inside PHP. You’ll study PDO (PHP Information Objects) and how you can 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 can shield us from opening a large safety gap for SQL injection assaults in our software. Use them. All the time.
Looking out Information
Looking for info in a database is definitely simple to do. It isn’t Google-level looking out, however it’s helpful generally. I will present you the way on this lesson.
Modifying and Deleting Information
A number of the best issues we will do with a database are modifying and deleting data. You will learn 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 gives a brand new function that permits you to add readability and suppleness to your perform calls. We’ll have 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 learn 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’ll have an opinion or two on the topic…
The next tutorials will enable you to study extra PHP string tips.
Conclusion
We coated loads on this PHP tutorial: from PHP variables and syntax to PHP arrays, loops, capabilities, and scope. You additionally discovered how you can retrieve and deal with person enter from PHP GET and POST requests, in addition to how you can use the session to persist knowledge between completely different pages. Not solely that, however we carried out an actual net app utilizing these easy PHP abilities!