PHP variables always start with a $ symbol. This makes them easy to spot in your code. PHP variables can hold any type of data, and you don't need to declare types upfront - you can change a variable's type simply by assigning a different kind of value to it.
Strings
Strings in PHP are similar to what you might know from other languages. You can create them with single or double quotes. The main difference is that double quotes allow you to embed variables directly in your string, while single quotes treat everything as literal text. Strings can be combined using the dot (.) operator:
Numbers
PHP has two numeric types you'll commonly use:
Booleans
In PHP, like in many other programming languages, a boolean represents two possible values: true or false.
Type Casting
PHP allows you to explicitly convert (cast) variables from one type to another. This is similar to JavaScript's parseInt or toString, but PHP uses a simpler syntax:
PHP also performs automatic type coercion, similar to JavaScript. This means PHP will automatically convert types when needed: