Home > Article > Backend Development > PHP test question summary (with reference answers)_PHP tutorial
1 The predecessor of JavaScript scripting language is B
A.Basic
B.Live Script
C.Oak
D.VBScript
2 Use CSS to decorate the text. If the text flashes, the value of text-decoration is D
A.none B.underline C.overline D.blink
3 The standard that XML is based on is C
A.HTML B.MIME C.SGML D.CGI
4 The tag title is placed between the tags B
A.html and html
B.head and head
C.body and body
D.head and body
5 The parameters for connecting images in the tag are: B
A. href B. src C. type D. align
6 The extension of the cascading style sheet file is: B
A html Bcss C xml D dib
7 Compared with previous versions, HTML4.0: C
A Added JavaScript support
B Added Flash technology
C Enhances the dynamics of web pages
D Added ActiveX technology
8 In HTML, the tag
functions as BA. Title mark B. Pre-typesetting mark C. Line transition mark D. Text effect mark
9 The line break mark in HTML language is B
A.html B. br C.title D. p
10 In HTML, the maximum value of x in the title font tag
is C A.4 B.5 C.6 D.1
11 Which of the following does not belong to the data definition language: A
A. select
B. create
C. drop
D. alter
13 The correct return value of mysql_select_db is: C
A. Returns 1 if enabled successfully, 0 if failed
B. A connection identifier is returned if successfully opened, false
is returned if failed.C. Return True if enabled successfully, False
if failed.D. Chengshi returns True when enabled, and returns an error number
if failed.
14 Look at the code. Which connection ID will be closed by the database close command? B
$link1 =mysql_connect("localhost","root","");
$link2 =mysql_connect("localhost","root","");
mysql_close();
?>
A. $link1
B. $link2
C. Close all
D. Report an error
15 Which operation does mysql_affected_rows() have no effect on? A
A. select
B. delete
C. update
D. insert
16 In the mysql_data_seek (query result pointer, data record location) function, what is the starting value of the data record location? D
A. 1
B. 2
C. 3
D. 0
17 The function to obtain the total number of records in the result set of the search statement is: C
A. mysql_fetch_row
B. mysql_rowid
C. mysql_num_rows
D. mysql_fetch_array
18 The correct statement about mysql_pconnect is: D
A. Multiple connections to the database
B. Same function as mysql_connect
C. Same function as @mysql_connect
D. Establish a persistent connection with the database
19 If you want to obtain the running status of the mysql database system, what function should be used? C
A. mysql_ping
B. mysql_status
C. mysql_stat
D. mysql_info
20 The function of mysql_insert_id() function is: B
A. Check the ID number when inserting the record next time
B. View the automatically growing ID value just inserted
C. Check how many insert operations have been performed in total
D. Check how many records there are
21 The correct function of the mysql_ping() function and the type of return value is: D
A. Check the status of the database system and return an integer value
B. Check the status of the database system, the return value is Boolean
C. Check whether the connection to the server is normal and return an integer value
D. Check whether the connection to the server is normal, the return value is Boolean
22 There is an existing cart program (cart.inc) which contains a method for adding items (add_item),
The following option can be used correctly add_item A
classCart {
var$items;
functionadd_item ($artnr, $num) {
$this-> items[$artnr] += $num;
}
}
?>
A.
require("cart.inc");
$cart = new Cart;
$cart -> add_item("10", 1);
?>
B.
require(cart.inc);
$cart= new Cart
$cart-> add_item ("10", 1)
?>
C.
require("cart.inc");
$cart= new Cart();
$cart-> add_item ("10", 1);
?>
D.
include("cart.inc");
$cart= new Cart();
$cart-> add_item ("10", 1);
?>
23 The correct statement about mysql_db_query and mysql_query is: C
A. The return value of mysql_db_query and mysql_query after executing the sql statement is the same. The resource number is returned successfully, and FALSE
is returned on failure.
B. You cannot use the mysql_query function to temporarily execute sql statements on another database, but mysql_db_query can
C. mysql_db_query will not switch back to the database it was previously connected to
D.mysql_query is functionally equivalent to mysql_select_db() +mysql_db_query()
24 The following code execution result A
mysql_connect("localhost","root","")
$result = mysql_query("select id,name from tb1");
while($row =mysql_fetch_array($result,MYSQL_ASSOC))
{echo "ID:" . $row[0] ."Name:" . $row[];}
?>
A. Report an error
B. Only print the first record
C. Loop and line feed to print all records
D. No results
25. The difference between mysql_connect() and @mysql_connect() is ( ) B
A @mysql_connect() will not ignore errors and display errors to the client
B mysql_connect() will not ignore errors and display errors to the client
C No difference
D Two functions with different functions
26. The number of executions of the statement for($k=0;$k=1;$k++); and the statement for($k=0;$k==1;$k++); are respectively: A
A infinite sum 0
B 0 and infinity
C is infinite
D are all 0
27. The method to read the form element value passed by the post method is: B
A $_post["name"]
B $_POST["name"]
C $post["name"]
D $POST["name"]
28. In php operators, the priorities from high to low are ( ) D
A relational operators, logical operators, arithmetic operators
B arithmetic operators, relational operators, logical operators
C logical operators, arithmetic operators, relational operators
D relational operators, arithmetic operators, logical operators
29. The value of the cookie is stored in () C
A in hard drive
B in program
C client
D Server side
30. To check the data type of a variable, use the function ( ) B
A type()
B gettype()
C GetType()
D Type()
31. To compare strings, press ( ) to compare. B
A Pinyin order
B ASCII code value
C Random
D sequence
32. The value of the type attribute of the check box is ( ) A
A checkbox
B radio
C select
D check
33. The value of the SESSION session is stored in ( )D
A on hard drive
B in web page
C client
D Server side
34. If you want to get the latest query information, which function should be used ( ) A
A mysql_info
B mysql_stat
C mysql_insert_id( )
D mysql_free_result
35. To view the value of a structure type variable, you can use the function ( ) B
A Print( )
B print( )
C Print_r()
D print_r( )
36. Which variable array in PHP always contains all cookie data sent by the total client ( ) B
A $_COOKIE
B $_COOKIES
C $_GETCOOKIE
D $_GETCOOKIES
37. Which of the following statements is wrong ( ) B
A gettype() is used to check the data type
B The variable that has not been assigned a value is 0
C unset() is considered NULL
D The most important thing about double-quoted strings is that the variable names will be replaced by variable values
38. The function of strtolower() function is ( )A
A Converts the given string to all lowercase letters
B Convert the given string to all uppercase letters
C Convert the first letter of the given string to lowercase letters
D Convert the first letter of the given string to uppercase letters
39. In HTML, the "value" of a table cell is stored in the ( ) tag B
A 〈body>
B 〈td>
C 〈tr>
D 〈table>
40. The function that converts a value or variable to character type is ( ) B
A intval( )
B strval( )
C str
D valint( )
41. The concatenation operator of strings in php is ( )D
A -
B +
C&
D.
42. Functions not supported by php functions are: C
A variable number of parameters
B Pass parameters by reference
C Pass parameters via pointer
D implements recursive functions
43. The type attribute value of the file box is ( ) A
A text
B hidden
C textarea
D checkbox
44. The function of operator "^" is ( ) C
A is invalid
B power
C bit is not
D bit XOR
45. In custom functions, the keyword for returning function values is ( )C
A returns
B close
C return
D back
46. To check whether a constant is defined, you can use the function ( ) C
A defined( )
B isdefin( )
C isdefined( )
D None
47. The correct description of the function of mysql_select_db is ( ) D
A Connect to database
B Connect and select database
C Connect and open the database
D Select database
48. In HTML, where should the title tag be placed?
In the A body tag
In the B head tag
in C script tag
in D table tag
49. Use the ( ) function to find the size of the array A
A count( )
B conut( )
C $_COUNT["name"]
D $_CONUT["name"]
50. You can use the () function to delete data from the head of the queue array. A
A array_push()
B array_pop()
C array_shift()
D array_unshift()
51. To embed javaScript in html, the tag that should be used is ( ) A
A 〈script language="javascript">
B 〈head> 〈/head>
C 〈body> 〈/body>
D 〈!--....//..>
52. The following code runs the result ( ) D
$A=array("Monday","Tuesday",3=>"Wednesday");
echo $A[2];
A Monday
B Tuesday
C Wednesday
D not shown
53. The function to create a new array is ( ) A
A array
B next
C count
D reset
54. The following incorrect variable name is ( ) B
A $_test
B $2abc
C $Var
D $printr
55. The method to read the form element value passed by the get method is: A
A $_GET["name"]
B $get["name"]
C $GEG["name"]
D $_get["name"]
56. The meaning of function vat_dump is ( ) C
A defines array
B traverse array
C Output variable-related information
D recursive array
57. The function of strtoupper() function is: A
A Converts the given string to all uppercase letters.
B Converts the given string to all lowercase letters.
C Converts the first letter of the given string to uppercase letters.
D Converts the first letter of the given string to lowercase letters.
58. The result of running the following code is ( ) B
if($i="")
{echo "a";}
else
{echo "b";
}
?>
A output a
B output b
C Insufficient conditions to determine
D Running error
59. In the str_replace(1,2,3) function, the name represented by 1 2 3 is ( ) B
A "replacement string", "replaced string", "source string"
B "replaced string", "replaced string", "source string"
C "source string", "replacement string", "replaced string"
D "source string", "replaced string", "replacement string"
60. When browsing the web, what part of the HTML do you see? C
A title
B table
C body
D head
61. The function of operator "%" is ( ) C
A is invalid
B Rounding
C Take remainder
D except
62. The data type returned by the file() function is () B
A array
B string
C integer
D Depends on the document
63. Assume $a=5, and $a+=2, then the value of $a is C
A. 5 B. 6 C. 7 D. 8
64. In the following description about MYSQL, the wrong one is D
A. MYSQL is a truly multi-threaded, single-user database system
B. MYSQL truly supports multiple platforms
C. MYSQL fully supports ODBC
D. MYSQL can mix tables from different databases in one operation
65. The comparison operator in PHP is B
A. = B.! C. = = D. &
66. The way to define activity variables in PHP is B
A. VAR B. $ C. $$ D.&
67. PHP expression $foo=1+”bob3”, then the value of $foo is A
A.1
68. PHP’s bitwise operators do not include DA.& B. | C. ~ D. !
69. The correct statement about PHP variables is D
A. PHP is a strongly typed language
B. When declaring PHP variables, you need to specify the type of the variable
C. The character used in front of the variable name when declaring PHP variables is "&"
D. When a PHP variable is used, the context will automatically determine the type of the variable
70. The delimiter symbol used when embedding HTML documents in PHP is D
A. Start with ""
B. Start with "- -" and end with "- -?>"
C. Start with "<%- -" and end with "- - %>"
D. Start with "
"
71. In PHP syntax, assuming that $a=”hello” and $b=”china” are known, how to operate C
to get the string of “hello china”
A. $a+$b B. $a-$b C. $a.$b D. $a+=$b72. To configure the PHP environment, just modify A
A. php.ini B. http.conf C. php.sys D. php.exe
73. Among the following commands, the one that is not an output command of PHP is D
A. echo B. printf() C. print D. write
74. The way to define constants in PHP is C
A. VAR B. dim C. define() D. undefined()
75. There are the following PHP statement segments
If ($a)
print “true”;
else
print “false”;
?>
To output "false", $a should be D
A. 10 B. –3 C. “true” D. “0”
76. It is known that $g=14, then the PHP expression $h=$g+=10, the result after operation is A
A. $h=$g=24 B. $h=10,$g=24 C. $h=10.$g=14 D. $h=24,$g=10
77. The operator used to call a method or attribute of an object in PHP is B
A. =>
78. Suppose $a=5, there is $b=($a--), then $b is BA. 4 B. 5 C, 6 D. 0
79. The purpose of the mark
is BA. Segmentation command B. Line feed command C. End command D. Print command
80. The function used to delete the current directory in PHP is: D
A. chdir B. cd C. opendir D. rmdir
The second block, programming questions (10 points for each question, totaling 20 points)
1. Use PHP to implement a user login program. The user table structure in database TEST is as follows:
user(userid char(8),password char(6))
//The pseudo code is as follows
$link=mysql_connect("$dbhost","$dbusername","$dbpassword");//Connect to the database
Mysql_select_db("$dbname");
//Write sql statement
$sql="select ...";
$resource=mysql_query($sql,$link);
if(mysql_fetch_row($resource)){
echo "Congratulations on your successful login";
}else{
echo "This user does not exist";
}
2. In MYSQL, the contents of the student table in the database "study" are as follows:
id name sex
9701 Wang Male
9702 Zhang male
9703 li female
The parameters for connecting to the database server are: ("localhost", "root", "1234")
Please use PHP language to write a program to delete a data record with ID 9701
$link=mysql_connect("localhost","root","1234");//Connect to the database
Mysql_select_db("study");
//Write sql statement
$sql="delete from student where id=9701";
$boolean=mysql_query($sql,$link);
if($boolean){
echo "Delete successfully";
}else{
echo "Deletion failed";
}
?>
4. Write the results of running the following program and write down the general process of running it (10 points)
class test{
var $a,$b;
function test($a,$b){
$this->a=$a;
$this->b=$b;
}
function getA(){
Return $this->a;
}
function getB(){
Return $this->b;
}
function xprint(){
echo "a=".$this->a." b=".$this->b;
}
};
class test1 extends test{
var $c,$d;
function test1($a,$b,$c,$d){
$this->a=$a;
$this->b=$b;
$this->c=$c;
$this->d=$d;
}
function getC(){
Return $this->c;
}
function getD(){
Return $this->d;
}
function xprint(){
echo "a=".$this->a." b=".$this->b." c=".$this->c." d=".$this->d;
}
};
$x=new test(0,0);
$x->xprint();
echo "
n";$y=new test1(1,2,3,4);
$y->xprint();
?>
a=0 b=0
a=1 b=2 c=3 d=4