Chapter 2 Flashcards
What is wrong with the following example?
<title>Mixing HTML and PHP</title>
<?php </p>
print “
It’s such a perfect day!
“;
?>
Some paragraph text.
The
tag is within the PHP code. You want to try to keep your PHP and styles seprate.
What does a single line of PHP commented code start with?
// This is a singe line of commented PHP code
/ This is how you comment out a single line of PHP code.
True or False
False:
// This is how you comment out a single line of code
How do you comment out several lines of PHP code at once?
/* This is how
you would
comment out
several lines
*/
Is this a good example of commented code?
Yes or no and why?
/*
We are formating phone numbers by stripping all characters
then putting parens around the first 3 numbers adding a
space then grouping the next 3 numbers adding a dash
then the last 4 numbers
*/
No.
You want to be concise.
/*
The business has a requirement that all phone numbers be
formatted with the (123) 123-1234 format
*/
What are the Basic DATA Types that PHP Supports?
- Integers
- Floats
- Strings
- Booleans
What is an Integer?
- An integer is a basic data type php supports.
- Integer is a whole number
$a = 1234; // decimal number
$a = -123; // a negative number
$a = 0123; // octal number (equivalent to 83 decimal)
$a = 0x1A; // hexadecimal number (equivalent to 26 decimal)
$a = 0b11111111; // binary number (equivalent to 255 decimal)
?>
What is are Floats?
- Floats are a basic data type PHP supports.
- Floats are fractions
- Floats are floating point numbers also known as:
- floats
- doubles
- real numbers
$a = 1.234;
$b = 1.2e3;
$c = 7E-10;
?>
What is the difference between Integers and floats?
Integers are whole numbers and floats are fractions
(i.e. 1, 2, 3 vs. 1.5, 2.3, 6.6)
What is a String?
- A basic data type supported by PHP
- a group of characters encolsed in either single or doubl;e quotes.
- Quotes must match
“This is a string”
‘This is also a string’
“This is ‘actually’ a string”
‘This is another “example”’
What does a document method of quoting strings look like?
print <<<eof>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus vulputate,</p>
<p>arcu a pellentesque viverra, elit metus pretium dui, nec congue ligula</p>
<p>velit vitae nunc. Aliquam est elit, faucibus vitae tincidunt sed, venenatis</p>
<p>vitae urna. Duis dignissim vel odio ac convallis. Suspendisse sodales viverra</p>
<p>ante, in consectetur nulla finibus a. Integer faucibus auctor ipsum, nec</p>
<p>tincidunt metus mattis id. Morbi non leo tristique, facilisis neque a,</p>
<p>volutpat purus. Class aptent taciti sociosqu ad litora torquent per</p>
<p>conubia nostra, per inceptos himenaeos.</p>
<p>EOF</p>
<p> </p>
</eof>
What does a document metho of quoteing strings start with and end with?
print <<<eof>
<p>This is the string here.</p>
<p>This is the string here.</p>
<p>EOF</p>
<p> </p>
</eof>
A boolean is a number.
True or False
False.
A boolean is a logical value of either true or false.
What is a boolean?
- A basic data type supported by PHP
- a logical value that is either true or false.
What are the Composite DATA Types supported by PHP?
- Arrays
- Objects
- NULL
- Resources