PHP Lessons - Lesson 4 - PHP Numeric Variables
In the previous lesson, we explored string variables. Now, let’s take a look at numeric variables. The simplest type of number is the integer.
Integers in PHP
Integers are whole numbers in the range from –2,147,483,648
to 2,147,483,647
. This range is determined by the 32-bit memory space used to store integers.
PHP Lessons - Lesson 5 - PHP Logical Variables
So far, we’ve learned that PHP supports numbers and strings. But this is not all—this lesson introduces another type of variable: Boolean variables. They are called Boolean because they are used to build logical structures in code.
PHP Lessons - Lesson 6 - PHP Operators
We’ve already explored string and numeric variables, and learned that numeric variables in PHP can be of various types: integers, floats, booleans. Now it’s time to learn how to operate on them, modify them, and perform arithmetic.
Below are tables illustrating the use of different PHP operators.
PHP Lessons - Lesson 7 - PHP Functions and Functional Programming
I think we've reached the point where it's time... it's time to finally start programming. After this lesson, you can say you've written code in PHP. Quite often, you'll need to reuse pieces of code on different pages or in different PHP files. To avoid duplicating code, PHP provides functions.
PHP Lessons - Lesson 8 - The if statement
Quite often, depending on circumstances, we have to make decisions. In programming—just like in life—actions depend on conditions. In life we use our head to make decisions, in PHP we use the if statement. For example: if it rains, I’ll take an umbrella; if it’s warm, we’ll go to the beach. In PHP, we evaluate expressions for truth and perform actions accordingly:
PHP Lessons - Lesson 8-2 - The switch statement
In the previous lesson, we learned about the if
statement. The if
statement allows us to check a condition and execute specific actions based on the result.
Now imagine you need to perform ten different checks and execute different actions based on each result. Sure, you could write this using multiple if
statements:
PHP Lessons - Lesson 9 - Recursion
In the previous lesson, we explored the use of functions in PHP. Now, we’ll dive deeper into how functions can be used. Previously, we used functions like this:
<?php function myFunction() { // function declaration } $x = myFunction(); // function call ?>
But what happens if we call a function from within itself?
PHP Lessons - Lesson 10 - Arrays
Up to this lesson, we’ve only been working with numeric and string variables. Now, let’s explore arrays in PHP. Arrays can contain both numeric and string variables, which is why they are called arrays.
PHP Lessons - Lesson 11 - Functions for Working with Strings and Arrays
We already know different data types and some functions for working with them. In fact, PHP has a huge number of built-in functions — so many that a full review would take more than one textbook. So let's focus on a few essential ones. We'll start with how to convert an array into a string, and then back from a string into an array.