Chapter 2 Flashcards

1
Q

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.

A

The

tag is within the PHP code. You want to try to keep your PHP and styles seprate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a single line of PHP commented code start with?

A

// This is a singe line of commented PHP code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

/ This is how you comment out a single line of PHP code.

True or False

A

False:

// This is how you comment out a single line of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you comment out several lines of PHP code at once?

A

/* This is how

you would

comment out

several lines

*/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

*/

A

No.

You want to be concise.

/*

The business has a requirement that all phone numbers be

formatted with the (123) 123-1234 format

*/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the Basic DATA Types that PHP Supports?

A
  • Integers
  • Floats
  • Strings
  • Booleans
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an Integer?

A
  • 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)
?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is are Floats?

A
  • 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;
?>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between Integers and floats?

A

Integers are whole numbers and floats are fractions

(i.e. 1, 2, 3 vs. 1.5, 2.3, 6.6)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a String?

A
  • 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”’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does a document method of quoting strings look like?

A

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>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does a document metho of quoteing strings start with and end with?

A

print <<<eof>

<p>This is the string here.</p>

<p>This is the string here.</p>

<p>EOF</p>

<p> </p>

</eof>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A boolean is a number.

True or False

A

False.

A boolean is a logical value of either true or false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a boolean?

A
  • A basic data type supported by PHP
  • a logical value that is either true or false.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the Composite DATA Types supported by PHP?

A
  • Arrays
  • Objects
  • NULL
  • Resources
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an Array?

A
  • A composite type supported by PHP
  • An array is a collection of valuse.
17
Q

What is a NULL Data Type?

A
  • A composite type supported by PHP
  • NULL represents a variable with no data value.
18
Q

What is a respource data type?

A
  • A composite type supported by PHP
  • A reference to an external resource
  • Used for working with files and databases
19
Q

What are objects?

A
  • A composite type supported by PHP
  • A way of representing every day data.
20
Q

What is gettype()?

A

gettype - gets the type of variable

<?php gettype($myVariable); ?>

21
Q

What kinds of variables does PHP support?

A
  • Predefined
  • User-Defined
  • Form Variables related to names in an HTML form
22
Q

What are the valid variable names supposed to start with?

A
  • All variables start with a $ followed by a letter or an _

$name1

$price_tag

$_abc

$Abc_22

$A23

23
Q

The following are all valid variable names.

True or False?

$10names

box.front

$name#last

A-23

$5

A

False.

All variables start with a $ followed by a letter or an _

24
Q

What is String Interpolation?

A

The process of evaluating a string literal containing one or more placeholders, yielding a result in which the placehoilders are replaced with their corresponding values.

25
Q

The following is NOT an example of String Interpolation.

True or False.

A

False.

String Interpolation is the process of evaluating a string literal containing one or more placeholders, yielding a result in which the placehoilders are replaced with their corresponding values.

26
Q

The following is an exaple of concatenation.

True or false?

<?php echo “Hello $name_variable” ?>

A

False. It is an example of String Interpolation.

String Interpolation is the process of evaluating a string literal containing one or more placeholders, yielding a result in which the placehoilders are replaced with their corresponding values.

Concatenation looks like this, using a . to concatenate.

<?php echo “Hello” . $name_variable ?>

27
Q

The following is an exaple of concatenation.

True or false?

<?php echo “Hello” . $name_variable ?</p>

A

True.

28
Q

What does Concatenation mean?

A

Concatenation is the action of linking things together.

In PHP you use the . to concatenate.

<?php echo “Hello” . $name_variable ?>

29
Q

What are scaler types?

A
  • Boolean
  • Integer
  • Float (floating-point number aka double)
  • String