Intro to PHP Flashcards
echo does what?
prints something out
what is echo format?
echo “text or content to be printed”;
what do we put at end of echo statement?
a ; so it looks like this: echo “text or content to be printed”;
what is a variable?
a variable is a container for a value - it can be declared once and then re-used.
how do we define a variable?
with a $
example of a variable?
$characterName = “joe” note text uses quotation marks
how is php executed?
in order
What would happen after line 6 and why?
“;
echo “He was $characterAge <br></br>”;
$characterName = “Mike”;
echo “He liked $characterName<br></br>”;
echo “Did not mind being $characterAge”;
?>
Name would change to Mike because this line changed the variable:
$characterName = “Mike”;
What is the difference between storing text and numbers in a variable?
text uses “”, numbers don’t need quotes
what is a string in php?
a string is plain text
a string always needs?
””
2 types of numbers as variables?
integer is a whole number - no decimal point
floating point number or floats has a decimal
A boolean
is a true or false value
Example of a boolean?
$isMale = true (can be true or false)
the 5 types of variables we just learned?
string is text with "" integer is a whole number a floating point number or floats has a decimal a boolean is true or false null has no value
a string is?
plain text
example of printing out a string
echo “my string”;
can use a variable as a container for a string?
yes for example: $phrase = “toasty toes”;
how to print the toasty toes?
echo $phrase;
a function can modify a string
yes
what’s a function to change a string to lower case?
echo strtolower($phrase);
True or False? functions are used to find out information about and to modify strings
true
what’s a function to change a string to upper case?
echo strtoupper($phrase);
what does a string function do? Can find out information about string or modify a string. They seem to start with?
str then the function - so strtolower changes to lower case