Basic PHP Problems

Source: Internet
Author: User
1. Use PHP to print the previous day's time format: 2013-04-2222: 21: 21 echodate (Y-m-dH: I: s, strtotime (-1day )); 2. echo (), print (), print_r () Differences echo and print can both output strings, but no results are returned, print can output formatted strings, while print_r is usually used to print information about variables, such as arrays.

1. Use PHP to print out the previous day's time format: 2013-04-2222:21:21 echo date ('Y-m-d H: I: s ', strtotime ('-1 Day'); 2. echo (), print (), print_r () Differences echo and print can both output strings, but no return, print can output formatted strings, while print_r is usually used to print information about variables, such as arrays.

1. Use PHP to print the time format of the previous day in the format of 2013-04-22.

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

2. Differences between echo (), print (), and print_r ()

Echo and print can both output strings, but no return value. print can output formatted strings. print_r is usually used to print information about variables, such as arrays.

3. Implement string Inversion

Strrev ()

4. methods to optimize the MYSQL database

1) Optimize the index

2) Slow query logs

3) locate SQL query

5. Use PHP to write code that shows the Client IP address and Server IP address.

Echo $ _ SERVER ['remote _ ADDR '];

Echo $ _ SERVER ['server _ ADDR '];

6. What is the difference between the include statement and require statement? To avoid multiple inclusion of the same file, what can be used instead?

Both include and require only contain documents, but require will produce fatal errors, while include only generates warnings, which can be replaced by require_once and include_once.

7. How to modify the SESSION survival time

Use session_set_cookie_params ('20140901 ');

8, there is a web address, such as Baidu: http://www.baidu.com how to get its content

$ Context = stream_context_create (array (

'Http' => array (

'Timeout' => 1 // set a timeout time, in seconds

)

));

File_get_content ('HTTP: // www.baidu.com ');

9. In HTTP1.0, Status Code 401 indicates that authorization is not received. If the "file not found" prompt is returned, the header function is available, and its statement header ('http1. 0 404 Not Found ')

10. In PHP, heredoc is a special string and its end mark must be?

The ending mark cannot contain any other character ';'

11. Differences between passing a value in PHP and passing a reference. When will the value be passed for reference?

Modification to the transferred variable in the function does not affect the value of the variable to be passed in (the value is re-assigned to the variable in the function );

Transfer variable reference. Any operation in the function is equivalent to the operation on the transfer variable, and the transfer of large variables has a high timeliness rate.

12. What is the role of the error_reporting function in PHP?

Set error severity

Error_reporting (0); // Disable Error Reporting

Error_reporting (E_ERROR | E_WARNING | E_PARSE); // reports runtime errors

Error_reporting (E_ALL); // report all errors

13. What is the JS steering function? How to introduce an external JS file?

Location. href

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.