PHP Basic Knowledge test questions

Source: Internet
Author: User
Tags explode php language php definition

One: Choice question

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

A:windows system If this is the WMP,

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 '); One less of the values

B:create table (Code int primary key); Missing a table name

C:update users code= ' p002 ' where code= ' p001 '; A set is missing.

D:select code as ' code ' from users;

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

A: Clients need to install client to open on browser, do not need to install client

B: Some programs that do not need to be installed to use the browser also need to be installed after use such as CMS

C: Web system based on browser

D: Systems that do not require a server require a server for each program

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

A:echo Output string

B:print Output string

C:var_dump () The value of the output type variable

The D:print_r () output array

5. The PHP definition variable is correct (B)

A:var a = 5; JS Definition method

B: $a = 10;

C:int B = 6; Strong type Definition Method

D:var $a = 12; No Var required

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 quotation marks are fast, single quote speed is slow, A and B are not defined by speed difference

C: Single quotation mark inside can parse escape character can be output, cannot parse

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 definition equals 1

+ + $x; X equals 2.

$y = $x + +; The x value is appended to Y, and the x self plus 1 equals 2!! If it's + + $x it's 3.

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

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

The A:implode () method can disassemble a string into an array explode can

B:str_replace () can replace a string at a specified position the word is find replace

C:SUBSTR () can intercept strings

D:strlen () The length of the string can not be taken to get the length

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

<?php

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

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

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

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 following functions should be used at the horizontal line: (B)

<?php

$email = ' [email protected] ';

$str = ____ ($email, ' @ ');

$info = ____ ('. ', $str);

____ ($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 strong type starting with "0" is correct

B. The subscript of an array can be a string

C. The element type in the array must be consistent and can be stored

D. The subscript of an array must be contiguous and not necessarily continuous

12. Which of the following descriptions is wrong? (AC)

A. The constructor and destructor of the parent class are not automatically called.

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

C. Static members defined in the parent class, and can not be called directly in the child class to invoke the

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

13. The statement about exit () and Die () is correct (CD)

A, when the exit () function execution will stop executing the following script, and Die () can not do two

B, when the Die () function execution will stop executing the following script, and exit () can not be able to terminate the program

The C, Die () function is equivalent to the exit () function

D, die () function is not directly related to the exit () function

14, the following program operation results (B)

<?php
$nextWeek = time () + (7 * 24 * 60 * 60);
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

Functionprint_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";

Functionprint_a ()

{

$A = "Phpmysql!";

Global $A; Globals $A Global Variables

Echo $A;

}

Echo $A;

Print_a ();

?>

A Hello

B Phpmysql!!

C Hello Hello

D Hello Phpmysql!!

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

$a = "AA";

$AA = "BB";

echo $ $a;

Aaa

B BB

C $AA

D $ $a

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

<?php

$a = 10;

$b = & $a;

Echo $b;

$b = 15;

echo $a;

?>

A 1015

B 1010

C 1515

D 1510

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

A echo $a + "Hello"

B Echo $a + $b

C echo $a. " Hello

D Echo ' {$a}hello ' if double quotes are possible

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

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];

?>

A will error!

B AA

C output is empty

D BB

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"; line wrapping can be wrapped within the source code

B:echo ' helloworld{$a} '; Can parse the value of variable a single quotation mark cannot parse a variable

C: $str =<<<aa

Hello World

AA;

This way you can define a string

D:print $a, "hello"; can output data without error print can output a string, cannot be output continuously

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

D:for loops can traverse an associative array to traverse an index

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

A:oop is an object-oriented abbreviation

B: Static members are class-owned

C: An ordinary member belongs to the object belonging to the class.

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 () {} is not in PHP

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

C:function Show (A, b) {} variable preceded by $ sign

D:functionshow (int $a) {} does not need to add int

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

A. $users [] = "John";

B. Array_add ($users, "John");

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:echorand () *10;

C:echo rand (1,10);

D:echorand (10);

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

A:echodate ("y-m-d h:i:s"); The date method is used to format the output time brackets are written in a formatted string

B:echo time (); The direct output time stamp

C:echodate (); Method will error

D:echotime ("y-m-d h:i:s"); You can't write double quotes in time.

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 block all errors
B:exit; The following statement can continue execution

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 a constructor and a normal function

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: Polymorphic occurs when each object invokes a method
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))

{

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

}

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

{

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

}

A:4b: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 B:unset () method cannot delete an element inside an array that can be deleted

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

d:php there are only indexed arrays and associative 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

C: The keyword used for paging queries is limit

D:mysql If the install only service does not install the interface can also be used normally

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

1. There are only two values for Boolean type data in PHP: True and False. (right) logic true and False

2. The symbol for connecting two strings in PHP is "+". (error) with a dot

3. PHP can use "scanf" to print out the results. (Error) echo print

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

5. You need to define the variable type before using PHP variables. (error) does not need to automatically determine the type based on the value behind it

6. in php, "= =" means "equals". (correct) An equal sign represents an assignment, and a double equals equals

7. Both the while and the Do-while statements evaluate the condition before executing the loop body. (error) While is the first to judge the condition Do-while is the first to execute the loop body and then judge

8. "Break" means to jump out of a loop. (right) Continue is jumping out of the current cycle

9. If you omit the keyword key when defining an array, the third element of the array has a keyword of 3. (error) should be 2

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

PHP basic Knowledge test question

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.