ch3 questions Flashcards
What tag is used to cause PHP to start interpreting program code? And what is the short form of the tag?
<?
the short form is deprecated
What are the two types of comment tags?
// single line comment /* multiline comment */
Which character must be placed at the end of every PHP statement?
;
Which symbol is used to preface all PHP variables?
$
What can a variable store?
numbers, strings, arrays
What is the difference between $variable = 1 and $variable == 1?
$variable = 1 declares $variable as 1
$variable == 1 compares $variable to 1
Why do you suppose an underscore is allowed in variable names (e.g., $current_user) whereas hyphens are not (e.g., $current-user)?
Because the hyphen ( - ) is also a subtraction operator
Are variable names case-sensitive?
Yes
Can you use spaces in variable names?
No
How do you convert one variable type to another (say, a string to a number)?
To convert a variable type to another, reference it and PHP will automatically convert it for you.
What is the difference between ++$j and $j++?
++$j increment before
$j++ increment after
Are the operators && and ‘and’ interchangeable?
Yes but && has higher precedence than and
How can you create a multiline echo or assignment?
Using heredoc tags or quotation marks <<<_TAGNAME multiline echo _TAGNAME; (the closing tag should be at the beginning of a line and followed by a semicolon, nothing else can be on the line)
Can you redefine a constant?
No
How do you escape a quotation mark?
By prefacing it with \