PHP is a recursive acronym for "PHP Hypertext Preprocessor". It a programming language that allows you to create dynamic pages and interact with databases. In the following tutorials we will cover the basics of PHP. We'll start with how to start each and every PHP script you make.
When learning any program language the first thing they usually do is teach you to write "Hello World" on the screen. PHP has two ways of printing text on the screen:
print "Hello World!"; echo("Hello World!"); Both of those statements would give you the same output:
Print and Echo are both php statements, every time you use a statement in php you have to end it with a semi-colon.
What sets PHP apart from HTML is variables. Variables are a storage location with a name that can be assigned a value. Here is how you can define a variable:
$int = 1; $boolean = true; $string = "string"; $float = .1233; $double = 3.14;
There are five basic types of variables:
Int - Integer 1,2,3,4,5
Boolean - True or False or 1 = true, 0 = false
String - Text
Float - Decimals .1,.2,.3,.4
Double - Float and Int combined 1,1.0,1.2
You might be wondering why there is an int and a float and then a double that combines the two. There is no real answer to that question, thats just the way it is. But you don't have to worry about it. PHP knows when its looking at a variable when the statement starts with a $ this makes your variables universal. Meaning you can define a variable as an int but later in your code change it to a string. PHP doesn't care. All that matters is that you have the $ before your variable name.