Free course
Learn PHP Online in 25 Hours
Learning to program is not an easy and time-consuming process. Learning the syntax of the language is the easiest and shortest part of the journey, but you can't start without it. This course is devoted to the basics of writing programs in PHP. It prepares the groundwork for writing meaningful programs
18 hours32353 students75 lessons with practice in the browser
Start LearningSign UpPHP Basics
PHP is one of the most popular programming languages in the world. More than 80% of websites on the Internet are written in this language.
We'll learn PHP from scratch, starting from the very basics. The first module is a springboard for writing meaningful programs. In it, we'll show you how to write your first code in PHP. We'll tell you what comments are and why they're needed. We'll also look at testing by checking your solutions as an example.
Arithmetic
Modern programs are created to serve businesses, help with daily life, and provide entertainment. But they're still based on calculations. The easiest and most basic topic in programming is arithmetic. In this module, we'll translate arithmetic operations into programming language and talk about the priority of operations. We'll also tell you what a linter is and why it might have a go at you.
Strings
Text in programming is called “strings”, and strings aren't as simple as they seem. How do I output a phrase that has both single and double quotes? How do you deal with text in general, since the computer knows nothing about letters! The module focuses on various aspects of writing, from quotation marks and escaping to encodings.
PHP Data Types
PHP is a language with weak typing and immutable primitive data types. What happens if we try to multiply a number by a string? How does PHP know what type of data it's looking at? And what does PHP do when it sees a type mismatch? You'll find the answers to these questions in this module.
Variables
- 20. What is a variable
- 21. Changing a Variable
- 22. Choosing a variable name
- 23. Errors when handling variables
- 24. Expressions in definitions
- 25. Variables and concatenation
- 26. Variable naming
- 27. Magic numbers
- 28. Constants
- 29. Magic constants
- 30. Interpolation
- 31. Extracting characters from string
- 32. Heredoc
Information can be put into special "containers" and reused as many times as we want. Such containers are called variables. They help to make code easier to read and avoid unneccessary repetition.
Calling functions
Functions exist to express any sort of operation in programming created by the user. Functions are the bricks that programmers use to build systems. In this module, we'll learn how to use the functions that have already been created. We'll look at function signatures in the documentation and figure out how to use them. We'll learn about the standard libraries, which store thousands of functions. It's impossible to learn every single function, but every programmer should know where to look for the function documentation they need.
Let's get started
Definition of functions
Defining your own functions makes it much easier to write and maintain programs. For example, the ability to define functions allows you to combine multiple complex operations into one; all the complexity can be hidden behind one simple function. Learning how to write functions is the first step toward building genuinely useful programs. And we can help you with that. In this module, you'll create your first function and learn how to name it (and the variables and constants as well) in a way that you can understand.
Logic
Logical expressions allow you to answer questions that arise when a program is running. Has the user been authenticated? Has the subscription been paid for? Is it a leap year? In this module, we'll study predicate functions, functions that ask and answer true or false questions. Let's practice writing these functions and then move on to more complex logical expressions.
Conditional constructions
The job of predicate functions is to get the answer to a question. However, this usually isn't enough; you often need to perform a certain action depending on the answer. If and Switch are PHP constructs that allow the programmer to select the desired behavior depending on different conditions, which means skipping some instructions and execute others. We'll analyze them in practice in this module.
Cycles
Any code can be repeated dozens, thousands, or millions of times. When we combine loops with the other tools we know, like variables and conditions, it opens up many possibilities for building programs and complex systems. Here's a simple example. You need to find a specific phrase in a 500-page textbook. You remember the phrase, but not the page number. The easiest (and longest) way is to go through the pages one by one until you find the right one. Loops are needed to perform these repetitive actions.
Diving into the lines
СModern string encoding and handling of strings in PHP using functions for multi-byte encodings. Localization.
Date and Time
ПThe concept of time in computers. Hardware Timer and System Timer. Functions for working with date and time in PHP. Timezones
Are you ready?
Registration is not required