PHP Basic Questions

Source: Internet
Author: User
Tags echo date explode php language php definition php mysql

Php Basic Knowledge Test questions

Name: Class: Results:

This test is a total of 40 choice questions, 10 judgment questions, examination time 1.5 hours

One: Choice question (single choice, 2 per question points):

1. Lamp specific structure does not contain any of the following (A)

A:windows system

B:apache Server

C:mysql Database

d:php language

2. Which of the following SQL statements is correct (D)

A:insert into users (' p001 ', ' Zhang San ', ' Male ');

B:create table (Code int primary key);

C:update users code= ' p002 ' where code= ' p001 ';

D:select code as ' code ' from users;

3. Which of the following types is the correct description of the B/S Architecture (C)

A: Customers are required to install the client

B: You can use it without the need for installation

C: Web system based on browser

D: Systems that do not require a server

4. Which statement in PHP can output a variable type (C)

A:echo

B:print

C:var_dump ()

D:print_r ()

5. The PHP definition variable is correct (B)

A:var a = 5;

B: $a = 10;

C:int B = 6;

D:var $a = 12;

6. The difference between single and double quotation marks in PHP that contains a string is correct (D)

A: Single quote speed is fast, double quotation mark speed is slow

B: Double quotes fast, single quote slow

C: Single quotes inside can parse escape character as output

D: double quotes inside can parse variables

7. If x, y is an integer data, the following statement performs a $y result of (B)

$x = 1;

+ + $x;

$y = $x + +;

A:1 b:2 C:3 d:0

8. The following statement about string handling functions in PHP is correct (C)

The A:implode () method can split a string into arrays

B:str_replace () can replace a string lookup substitution at a specified location

C:SUBSTR () can intercept strings

D:strlen () cannot take the length of a string

9. The following code runs the result: (A)

<?php

$first = "This course are very easy!";

$second = Explode ("", $first);

$first = Implode (",", $second); divide spaces into commas

Echo $first;

?>

A this,course,is,very,easy,!

B This course are very easy!

C This course are very easy!,

D hint Error

10. The functions that should be used at the following horizontal lines are: (B)

<?php

$email = ' [email protected] ';

$str = _strstr (intercept)___ ($email, ' @ ');

$info = _EXPLODE (split string, split array)___ ('. ', $str);

Print_r (You can simply print the string and the number, and the array is displayed with the enclosed key and the list of merit, and begins withan array) ____ ($info);

?>

The output is:

Array ([0] = @thizlinux [1]=>COM[2]=>CN]

A:STRCHR, Split, Var_dump

B:strstr, Explode, print_r

C:strstr,explode, Echo

D:STRCHR, Split, Var_dump

11. The following statements are correct: (B)

A. The subscript of an array must be a number, and the strongly typed language standard starts with "0"

B. The subscript of an array can be a string

C. element types in arrays must conform to strongly typed language standards

D. The subscript of an array must be a continuous strong-type language standard

12. Which of the following descriptions is wrong? C

A. Ordinary members are object-owned

B. Member variables need to be decorated with public protected private, var keyword is no longer required when defining variables

C. A static member is a class belonging to an object

D. Classes containing abstract methods must be abstract classes, abstract classes cannot be instantiated

13, the statement about exit () and Die () is correct (C)

A, when exit () function execution will stop executing the following script, and die () cannot do

Execute this program, the following program cannot execute

B, when the Die () function execution will stop executing the following script, and exit () cannot do

Execute this program, the following program cannot execute

C, where the Die () function is used, you can also use the exit () function to replace

No difference between D, die () function and exit () function

14, the following program operation results (B)

<?php
$nextWeek = time () + (7 * 24 * 60 * 60); A time stamp used to get something at a certain moment.
Echo ' Now: '. Date (' y-m-d '). " \ n ";
Echo ' Next Week: '. Date (' y-m-d ', $nextWeek). " \ n ";
?>

A, get today's date (month-day)

B, get today's date (year-month-day) with next week's date (year-month-day)

C, get the current time (hours-minutes-seconds)

D, get the time between now and next week

15. The following code executes the result: (D)

<?php

function Print_a () {

$A = "Phpchina";

echo "A value is:" $A. " <p> ";

return ($A);

}

$B = Print_a ();

echo "B value is:" $B. " <P> ";

?>

A A value is:

The B value is:

B a value is:

The B value is: Phpchina

C A value is: Phpchina

The B value is: Phpchina

D A value is: Phpchina

The B value is:

16. The following code executes the result: (C)

<?php

$A = "Hello";

the scope of the FUNCTIONPRINT_A () variable is the function

{

$A = "php mysql!!";

Global $A; Variable A as a global variable can be accessed from this location to variables outside the function

Echo $A;

}

echo$a;

Print_a ();

?>

Ahello

bphp MySQL!!

Chello Hello

Dhello php mysql!!

17, the result of the following code output is (B)

$a = "AA";

$AA = "BB";

echo $ $a;

Aaa

Bbb

C$aa

d$ $a

18, the result of the following code output is (A)

<?php

$a = 10;

$b =& $a; & Take Address

Echo $b; Two variables point to a number at the same time, a change is changed

$b = 15;

echo $a;

?>

A1015

B1010

C1515

D1510

19, the PHP output stitching string is correct (C)

Aecho $a + "Hello"

Becho $a + $b

Cecho $a. " Hello

Decho ' {$a}hello ' cannot parse variable

20.404 error when viewing Web pages in a browser the probable cause is (B) Common Sense

A page source code error

b file does not exist

C Connection Error with database

D Insufficient Permissions

21. The result of the following code output is (D)

<?php

$attr = Array ("0" = "AA", "1" = "BB", "2" and "CC");

ECHO$ATTR[1]; weakly typed language features integer variable string

?>

A will error!

Baa

C Output is empty

Dbb

22. Which of the three main object-oriented features is not a encapsulation approach (B)

A to turn a member into private

b Turn Members into public

C Encapsulation method to manipulate members

D Use the __get () and __set () methods to manipulate members

23, the source Code of PHP is (A)

A Open B. Closed C. Need to purchase D. Completely invisible.

24, PHP How to output backslash (D)

A \ n B. \ r C. \ t D. \\

25. Which of the following does not belong to the three major features of OOP (B)

A: Package B: Overload C: Inherit D: polymorphic

26. The following statement about the string is correct (C)

A:echo "Hello\nworld"; in the page can be implemented in line feed source code, the Web page can not

B:echo ' helloworld{$a} '; The value of variable a can be parsed as-is output

C: $str =<<<aa

Helloworld

AA;

This way you can define a string

D:print $a, "hello"; output data not error print can only output one, for Echo can

27. The following statements are incorrect (D)

The A:list () function can be written to the left of the equals sign

The B:each () function can return the next element inside the array

C:foreach () can traverse the array while traversing the key and value

The D:for loop is able to traverse an associative array to traverse only the indexed

28, about the object-oriented statement is not correct (C)

A:oop is an object-oriented abbreviation

B: Static members are class-owned

C: Ordinary members are classes that belong to classes that represent the object

D: The $this keyword inside the class represents the object itself

29. The following defines the function in the correct way (B)

a:public void Show () {}

B:function Show ($a =5, $b) {}

C:function Show (A, b) {}

D:function Show (int $a) {}

30. Which of the following options does not add John to the users array? B

A. $users [] = "John";

B.array_add ($users, "John"); Not in PHP

C.array_push ($users, "John");

D. $users ["AA"]= "John";

31, the following in PHP can output 1 to 10 of the random number is (C)

A:echo rand ();

B:echo rand () *10;

C:echo rand (1,10);

D:echo rand (10);

32, the following in PHP can output the current time format like: 2016-5-6 13:10:56 is (A)

A:echo date ("y-m-d h:i:s");

B:echo time ();

C:echo date ();

D:echo time ("y-m-d h:i:s"); Take time stamp

33. Which of the following does not belong to the four elements of the function (D)

A: return type

B: Name of function

C: Parameter list

D: Access modifier

34. The following statement is correct (C)

a:@ symbol can mask all errors cannot be masked
B:exit; The following statement can continue execution after the program does not execute

C:10/4 the result is 2.5.

d:$ $a; this is wrong.

35. The following remarks about the constructor are incorrect (B)

A: To study a class, the first thing we want to look at is the constructor
B: There is no difference between the constructor and the normal function, the execution time is special.

C: Constructors perform relatively special

D: If a constructor is present in the parent class and a parameter is required, the subclass should also pass in the corresponding parameter when making the object.

36. The following statements about polymorphism are correct (D)

A: Polymorphism occurs when each object invokes a method that satisfies a condition
B: Polymorphism is caused by the definition of different functions within subclasses.

C: polymorphic generation does not require conditions

D: When the parent class refers to a subclass instance, because the child class overrides the method of the parent class, the differences that appear when the parent class refers to the corresponding function are called polymorphic.

37. The following code will output how many rows of data on the page (A)

$attr = Array (1,2,3,4);

while (list ($key, $value) = each ($attr)) pointer

{

Echo$key. " = ". $value." <br> ";

}

while (list ($key, $value) = each ($attr))

{

Echo$key. " = ". $value." <br> ";

}

A:4 B:6 C:8 D:12

38. The following statement is correct (C)

A: $attr represents an array, then the length of the array can be obtained by $attr.length the JS method
The B:unset () method cannot delete an element inside an array

An array of c:php can store any type of data

d:php only indexed arrays

39. The following statement is incorrect (B)

A: The keyword used by fuzzy queries is like
B: Sort query asc is descending, desc is ascending ASC Ascending desc Descending

C: The keyword used for paging queries is limit

D:mysql If you install only the service does not install the interface can also be used to install only the service, do not install the interface can also be used

40. The result of the following code output is (D)

$a = "CC";

$CC = "DD";

echo $a = = "CC"? "{$ $a}": $a;

A:cc
B: $a

c:$ $a

D:dd

Second, the judgment question (total Questions , 2 per question points)

1. There are only two values for Boolean type data in PHP: True and False. T

2. The symbol for connecting two strings in PHP is "+". F

3. PHP can use "scanf" to print out the results. F

4. At the end of each statement, ";" is added to indicate the end of the statement. T

5. You need to define the variable type before using PHP variables. F

6. in php, "= =" means "equals". T

7. Both the while and the Do-while statements evaluate the condition before executing the loop body. F

8. "Break" means to jump out of a loop. T

9. If you omit the keyword key ( index ) when defining an array, the third element of the array has a keyword of 3. F

10. Query data in MySQL database with SELECT statement. T

PHP Basic Questions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.