1.
How would you end a php tag?
Correct Answer
C. ?>
Explanation
The correct answer is "?>". In PHP, the closing tag for a PHP block is "?>". This is used to indicate the end of PHP code and to switch back to HTML mode. It is important to properly close PHP tags to ensure that the code is executed correctly and to avoid any syntax errors.
2.
What is echo and what do you need to use with echo?
Correct Answer
B. Echo is a function that outputs a string and uses quotes, " ", and a semi-colon ;
Explanation
Echo is a function in programming that is used to output a string. In order to use echo, quotes (" ") are needed to enclose the string that will be outputted. Additionally, a semi-colon (;) is used to indicate the end of the echo statement.
3.
To start a pHP tag, how would you do that?
Correct Answer
E. < ?pHp
Explanation
The correct answer is "< ?php". This is the correct way to start a PHP tag. The opening tag for PHP code is "< ?php" and it is followed by the PHP code that you want to execute.
4.
When commenting on code so that you know what the code is made for what do you use for pHP?
Correct Answer
C. // comment here
Explanation
In PHP, the double forward slash "//" is used to add a single-line comment. This comment is ignored by the PHP interpreter and is only meant for human readers to understand the purpose or functionality of the code. It is commonly used to provide explanations, documentations, or to temporarily disable specific lines of code.
5.
pHP variables begin with $
Correct Answer
A. True
Explanation
PHP variables begin with a dollar sign ($). This is a syntax rule in PHP, indicating that any variable in PHP code must be preceded by a dollar sign. This convention helps the PHP interpreter to distinguish variables from other elements in the code. Therefore, the statement "True" is correct.
6.
What are the super global variables?
Correct Answer
B. $_SERVER , $_POST , $_GET
Explanation
The super global variables in PHP are predefined variables that are always accessible, regardless of scope. These variables include $_SERVER, $_POST, and $_GET. $_SERVER is an array that contains information about the server and the execution environment. $_POST is an associative array that contains the values of variables sent to the current script using the HTTP POST method. $_GET is also an associative array that contains the values of variables sent to the current script using the HTTP GET method. These super global variables are widely used in PHP programming for various purposes such as accessing form data and server information.
7.
What is the escape character for carriage return?
Correct Answer
C. \r
Explanation
The escape character for carriage return is \r. This character is used to move the cursor to the beginning of the current line, allowing new text to overwrite the existing content on that line.
8.
You use a quote inside a quote
Correct Answer
A. True
Explanation
When using a quote inside a quote, it is important to use proper punctuation and formatting. This is commonly done when quoting someone who is already quoting someone else. By using quotation marks within quotation marks, it helps to distinguish between the original quote and the quote being referenced. This practice ensures clarity and accuracy when attributing quotes to their respective sources. Therefore, the correct answer is true.
9.
Referring to question 7 How would you do a quote inside a quote? Check all that apply
Correct Answer(s)
A. " hello ' this ' world "
B. ' Bon " Jovi " rules '
Explanation
The correct answer includes the examples "hello ' this ' world" and 'Bon "Jovi" rules'. These examples demonstrate the correct way to include quotes within quotes by using single quotes within double quotes or double quotes within single quotes.
10.
You use arrays in pHP
Correct Answer
A. True
Explanation
Arrays are a fundamental data structure in PHP that allow you to store multiple values in a single variable. They are used to group related data together and can be accessed and manipulated using their index or key. By using arrays, you can efficiently store and retrieve data, making it easier to work with large sets of information. Therefore, the statement "You use arrays in PHP" is true.