PHP Cheat Sheet for Beginners
Note: I am primarily using this as a study tool as I'm upskilling my foundational knowledge. With this in mind, this document is ongoing, and I'll likely be updating it weekly. Opening and closing tags: Note: omitting the closing tag at the end of a file can be beneficial so you don't have any unwanted white space at the end of the file Printing: echo 'This prints to the screen.'; Commenting: One line: # This is a one-line comment in PHP Multi-line: /* This is a multi- line comment in PHP */ Checking variable type: var_dump($var_name); Comparing Floats: Note: Comparing floats in PHP is tricky because of precision. The following is a workaround for that limitation. String Definitions: 'this is a string' "this is a string"

Note: I am primarily using this as a study tool as I'm upskilling my foundational knowledge. With this in mind, this document is ongoing, and I'll likely be updating it weekly.
Opening and closing tags:
Note: omitting the closing tag at the end of a file can be beneficial so you don't have any unwanted white space at the end of the file
Printing:
echo 'This prints to the screen.';
= 'This works too.'; ?>
Commenting:
One line:
# This is a one-line comment in PHP
Multi-line:
/* This is a multi-
line comment in PHP */
Checking variable type:
var_dump($var_name);
Comparing Floats:
Note: Comparing floats in PHP is tricky because of precision. The following is a workaround for that limitation.
String Definitions:
'this is a string'
"this is a string"
<<
String Interpolation:
or
echo 'this line prints a {$var}';
String concatenation uses a . rather than a + in PHP.
I used PHP's documentation as the source of my information here. Some of the code will be similar or identical.