Sie sind auf Seite 1von 3

Chapter 1, Getting Started with PHP

Creating Basic PHP Scripts, Short Quiz Answers 1. PHP code is embedded within a Web page. 2. To avoid having the file processed by the scripting engine unnecessarily. 3. The scripting engine processes the PHP code it finds within PHP code blocks and returns the results of the PHP script and any HTML or XHTML elements found in the PHP file to the client. Creating PHP Code Blocks, Short Quiz Answers 1. Unlimited 2. The standard PHP script delimiters are guaranteed to be available on any Web server that supports PHP. 3. Commas 4. The phpinfo() function provides diagnostic information for the current PHP configuration on the Web server. 5. A line comment begins with two forward slashes (//) or a pound symbol (#) and is used to add a single-line comment to code. A block comment begins with a slash followed by an asterisk (/*) and ends with an asterisk followed by a slash (*/), and is used to add a multiline comment to PHP code. Using Variables and Constants, Short Quiz Answers 1. A variable must be declared and initialized. This means that the variable must be created, named, and assigned an initial value. 2. You must pass the variable name to the echo or print statement. If you pass multiple arguments to the echo statement, you must separate the arguments with commas. 3. You make a constant name case-insensitive by adding a third argument of TRUE to the define() function.

Working with Data Types, Short Quiz Answers 1. PHP is a loosely typed programming language, which means that the variable can change after it is declared. PHP automatically determines what type of data is stored in a variable and assigns the variable type. 2. Integer 3. The value of an array element is accessed using the name of the arrayan opening and closing bracket surrounding the index number of the element (for example, $signs[1]). It is important to remember that an array index begins with 0. 4. count() 5. The print_r() function displays the index and values of each element in an array. The print_r() function should be enclosed in opening and closing <pre> tags. Building Expressions, Short Quiz Answers 1. The modulus operator, a percent sign (%) 2. An assignment operator assigns the value on the right side of the operator to the value on the left side of the operator. The compound assignment operator performs a mathematical calculation on the expressions on the left and right sides of the operator and assigns the new value to the operand on the left side of the operator. 3. A prefix operator (which is placed before a variable) performs the arithmetic operation before it is returned; the postfix operator (which is placed after the variable) performs the arithmetic operation after it is returned. 4. Associativity refers to the order in which operators of equal precedence execute. Some operators are evaluated on a left-right basis and others on a right-left basis.

Comprehension Check Answers 1. a .php

2. b. a comma (,) 3. c. # and d. // 4. a. */ 5. c. $SalesOrder 6. False 7. a. $MyVariable = "Hello"; 8. A data type is a specific category of information that a variable contains. Selecting the correct data type is important because it determines the manner in which the value is stored and how much memory the computer allocates for the data. 9. Assigning a value of NULL to a variable indicates that the variable does not contain a usable value. This ensures that the variable does not contain any data before you use it. 10. a. does not require data types of variables to be declared 11. a. zero 12. a. TRUE and b. FALSE 13. a. $Employees[0] 14. d. divides two operands and returns the remainder 15. a. TRUE 16. a. ++ and b. -17. c. the left operand and right operand both return a value of TRUE 18. b. FALSE 19. b. operator precedence 20. c. 20

Das könnte Ihnen auch gefallen