PHP Knowledge Clearance-Common Functions

1. In PHP, which of the following methods uses PHP to connect to the MySQL database?

mysql_connect()
mysql_query()
mysql_close()
None of the above
Analysis: PHP provides the mysql_connect() function to open the database connection, but the new version recommends using MySQLi or PDO to connect.

2. In PHP, which of the following functions is used to obtain environment variables in PHP?

search()
environment()
env()
getenv()
Analysis: PHP provides a getenv() function to access the values ​​of all environment variables.

3. Which of the following exception handling methods retrieve error messages when an error occurs?

getMessage()
getCode()
getFile()
getLine()
Analysis: PHP's abnormal message processing method is getMessage() to return the abnormal message.

4. Regarding variable naming rules, which of the following options is correct?

Variable names can start with letters or underscores.
Variable names can be composed of numbers, letters and underscores.
Characters such as +, -, %, (,) cannot be used as variable names. The
above options are all correctly
parsed: PHP variable naming rules: Beginning with numbers and'-', can start with letters or underscores, variable names can be composed of numbers, letters and underline transactions , and cannot use +, -, %, (,) and other characters as variable names (because of these special characters Has its own unique meaning in php)

5. Which of the following arrays represents an array with a numeric index?

Numerical arrays
Associative arrays
Multidimensional arrays
None of the above
Analysis: Numerical arrays-arrays with numerical indexes, values ​​are stored and accessed in a linear manner.

6. Which of the following functions creates an array?

array()
array_change_key_case()
array_chunk()
array_count_values()
Analysis: array() directly creates an array.

7. Which of the following methods can use PHP to parse XML documents?

simplexml_load_string()
loadxml()
All of the
above None of the above
Parsing: Both simplexml_load_string() and loadxml() can be used to parse XML documents. To create a SimpleXML object from an XML document stored in a string, pass the string to simplexml_load_string(), which returns a SimpleXML object.

Guess you like

Origin blog.csdn.net/weixin_54792157/article/details/113097288