Variables are like containers for storing information. In PHP a variable is declared by prepending a dollar ($) to the variable name. Unlike other programming languages, PHP has no command for declaring a variable – the variable is created the moment you first assign a value to it.
A variable name must either begin with a letter or the underscore character but it cannot start with a number. Besides, a variable name can only contain alphanumeric characters and the underscore.
In the example below we are going to declare a variable to store the name of country of a famous football star.
$country = "Brazil";
Declaring a variable is a statement in PHP and so we have to terminate it with a semicolon.
Geoffrey is an experienced software developer and open source evangelist. When not coding he writes and talks about current technology trends, small business tips and developer productivity hacks. He is no coffee addict.
How to Install Sublime Text 3 in Windows
How to Create a PHP Abstract Class
How to Create SVG Images
Interview With Alexey Pelykh – How To Be a Mobile App Developer Without a Degree in Computer Science
How to Become Efficient With a 5 Step Web Development Life Cycle
How to Become a Professional Android Developer in 6 Simple Steps