📄️ PHP Tags, Printing & Comments
Alright, let's get started with our first bit of PHP code! We will start with the basics and then move on to more advanced topics. I realize that some of you may already know this stuff, but remember that this is a course for people that are new to PHP, so we have to start at the beginning.
📄️ Variables
Variables are something that we have in virtually every programming language. Variables are used to store data. Think of them as a container that holds information. You can access that information at any time by calling the variable name.
📄️ Data Types
Every piece of data that you work with in PHP has a data type. A data type is a classification of the type of data that a variable or object can hold in computer programming. This isn't just in PHP. Every language has the concept of types. PHP has 8 primitive data types. We will go over each one in this lesson. We will also go over how to get the data type of a variable.
📄️ String Concatenation, Interpolation, and Escaping
So we have established that PHP has different data types. In this lesson, I want to focus on strings and something called string concatenation. This is a fancy way of saying that we can join strings together. I'm also going to show you a big difference between single quotes and double quotes. For now, we are going to focus on single quotes. Which is what I prefer to use. It's completely up to you on which one you use. My main language is JavaScript and I always use single quotes. So I've become accustomed to it. But I will show you the difference between the two when it comes to concatenation and something called variable interpolation.
📄️ Type Casting and Type Juggling
When dealing with types, there may be times when you need to convert a variable from one type to another. This is called type casting. PHP has two ways to do this. The first is called implicit type casting. This is when PHP automatically converts a variable from one type to another. This can also be called type juggling. The second is called explicit type casting. This is when you explicitly tell PHP to convert a variable from one type to another.
📄️ Variables Challenge
Instructions
📄️ Arithmetic Operators & Math Functions
I want to look at the arithmetic operators by doing some basic math and then look at some PHP core functions that deal with numbers and math.
📄️ String Functions
I know that we have not talked about creating functions yet. We will get to that very soon, but for now, I want to show you some common functions that have to do with strings that are built into PHP. This is not an exhaustive list, but it is a good start.
📄️ Working With Dates
Again, I know that we have not looked at creating custom functions, but I want to show you how to work with dates using the date() function. This is a very common function that you will use in your PHP career.