One Pager Cheat Sheet
PHP
is anopen-source scripting language
widely used for scripting the backend of a website, integrating well with HTML, CSS, and Javascript.- The
echo
language construct in PHP can be used to output string(s) without surrounding parentheses, and can take multiple parameters, as demonstrated by the exampleecho "Hello" . " World!";
. PHP echo is a language construct used to output strings and variables to the console.
- The
print
statement is a function that returns an integer value of1
when used to output strings and variables, unlike the language constructecho
which does not return a value. - The print statement
returns 1
and takes oneargument
which can beprinted
to theconsole
, but isslower
thanecho
. - The
gettype()
function in PHP is used to determine the data type of the input expression, with the example expressions being a String, an Array and an Integer respectively. - The 8 fundamental data types in PHP are
String
,Boolean
,NULL
,Array
,Integer
,Double
,Object
, andResource
. - An Indexed Array in PHP is a type of array that stores multiple values in a single variable, where each element has an integer index or
key
. - PHP supports
Indexed
,Associative
, andMulti-dimensional
arrays. - An
indexed array
is a collection of values that are accessed by a numericindex
starting at zero, which is a concept familiar to many programmers. - An associative array is a
data structure
in whichkey-value pairs
are stored and can be accessed using the keys. - A
multi-dimensional array
has arrays within arrays and is just like a matrix with more than one row, with either indexed or associative arrays. - PHP's
foreach
loop is an easy and syntactically simple way to iterate over arrays and objects. PHP foreach loop
is a specialized construct used to efficiently loop over associative arrays and access key-value pairs.$greetings_explode
is being set to the output of theexplode()
function, which splits astring
into an array, andgettype()
can be used to return the data type of a variable, so the output of the code will be "array".- The
explode
function in PHP splits a string into an array using a specific character as theseparator
. - The same value can have different data types, such as
string
andinteger
, so the answer is "Same value, different data types". - The
equal
operator (==) checks for equality in value, while theidentical
operator (===) also checks for equality indata type
. - Classes are
instantiated
wheninvoked
to create an instance of the class, which then has the same properties and methods as defined by the class. - A PHP class is a
template
orblueprint
for creatingobjects
. - An object is created with the
new
keyword and is an instance of a class, with the same attributes and methods as other objects of the same class.