FAQ 1 (with answers) and PHP with answers

Source: Internet
Author: User
Tags echo date php error php error reporting

FAQ 1 (with answers) and PHP with answers

1. Which three methods can be used to define strings in php:

Single quotation marks, double quotation marks, and delimiters

 

2. syntax for defining constants and static constants is:

Define ('constant name', 'constant value ')

Static $ var

 

3. Print the time of yesterday in php format: 22: 21: 21:

Date_default_timezone_set ('prc ');

Echo date ('Y-m-d H: I: s', time ()-60*60*24 );

Echo date ('Y-m-d H: I: s', strtotime ('-1 Day '));

 

4. To enable php error reporting, follow these steps:

Modify the configuration file display_errors = On, or ini_set ('display _ errors ', 'on ');

 

5. The function that serializes objects or arrays in php is:

Serialize ()

 

6. How to define access control for class members:

Public private protected

 

7. the following code is output in the browser:

<? Php

$ X = 87;

$ Y = ($ x % 7) * 16;

$ Z = $ x> $ y? 1:0;

Echo $ z;

?>

Result: 1

 

8. There is an employee table user [id, name, money], which writes an SQL statement to query the maximum value of money in the table:

SELECT max (money) FROM user

Write an SQL statement to query the top 10 people with the most money, sorted by money in ascending order:

SELECT * FROM user order by money desc limit 0, 10

 

9. Write a function to calculate the difference between two dates, for example, 2007-2-5 ~ The date difference between 2007-3-6:

Function getDays ($ d1, $ d2 ){

$ Nd1 = strtotime ($ d1 );

$ Nd2 = strtotime ($ d2 );

$ Days = ceil (abs ($ nd2-$ nd1)/(60*60*24 ));

Echo $ days;

}

 

10. write a php function to find the largest one from N integers ($ a = array (, 20);). Note: Do not use php functions such as max and sort:

Function getMax ($ m ){

$ V = 0;

Foreach ($ m as $ v1 ){

If ($ v1> $ v ){

$ V = $ v1;

}

}

Return $ v;

}

 

11. there is a 100-storey building with a pile of stones of the same size. The stones will be broken when they are dropped from a certain level of the Building (critical Floor, which algorithm can be used to obtain the critical floor as quickly as possible?

(1). Shi er's infinite bipartite method.

(2). Two stone child Segmentation Algorithms

14 27 39 50 60 69 77 84 90 95 99

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.