Ddchuxing -- Summary of php interview questions and ddchuxingphp questions

Source: Internet
Author: User

Ddchuxing -- Summary of php interview questions and ddchuxingphp questions

1. Differences between echo and print

Echo has no return value. print has return value 1. If the execution fails, false is returned. echo outputs faster than print because no return value exists. echo can output one or more strings, print can only output one string. print can be used for complex expressions, but not echo.

Q: Is echo a function? Echo is not a function, but a language structure. For more information, see http://www.cnblogs.com/m1001m/archive/2013/03/24/2978219.html.

2. array-related functions

There are too many, here to write a few good, the full version see http://www.runoob.com/php/php-ref-array.html

Array () to create an array.

Array_diff () compares the array and returns the difference set (only the key value is compared ).

Array_pop () deletes the last element (Out stack) of the array ).

Array_rand () returns one or more random keys in the array.

Array_replace () replaces the value of the first array with the value of the following array.

Array_reverce () returns an array in reverse order.

Array_shift () deletes the first element in the array and returns the value of the deleted element.

Array_slice () returns the selected part of the array.

Array_splice () deletes and replaces the specified Element in the array.

Arsort () sorts associated arrays in descending order by key value.

End () points the internal pointer of the array to the last element.

In_array () check whether the specified value exists in the array.

Krsort () sorts arrays in reverse order by key name.

Next () moves the internal pointer in the array one by one.

Reset () points the internal pointer of the array to the first element.

3. Example of magic functions in phpAlas, I was drunk when I tried it.

There are different interpretations of magic functions in various fields. You can refer to them to see which one is easier to understand.

_ Construct () allows constructor before instantiating a class.

The _ destruct () destructor allows you to perform some operations or perform some functions before destroying a class.

_ Get (string $ name) is used to obtain private property values. When reading an object property, if the property exists, the property value is directly returned. If the property does not exist, the _ get function is called.

_ Set (string $ name, mixed $ value) is used to set Private attributes. If an object property exists, the value is assigned directly. If the property does not exist, the _ set function is called.

_ Call (string $ name, array $ arguments) is used to monitor incorrect method calls. An object calls a method. If a method exists, it is called directly. If the method does not exist, the _ call function is called. When a non-existing or inaccessible method is called in a static method, the _ callStatic (string $ name, array $ arguments) method is called.

_ Tostring () is called directly when an object is printed. For example, echo $ obj; or print $ obj.

_ Clone () is called directly when an object is copied. For example, $ t = new Test (); $ t1 = clone $ t.

_ Sleep () serialize is called. If the object is large and you want to delete it and serialize it again, consider this function.

_ Wakeup () unserialize () checks whether a _ wakeup () method exists. If yes__The wakeup method is used to prepare the resources required by the object in advance.

_ Isset () is called to check whether an object's attribute exists. For example, isset ($ c-> name ).

_ Unset () unset the attribute of an object is called. For example, unset ($ c-> name ).

_ Set_state () is called when var_export is called. Use the return value of _ set_state as the return value of var_export.

_ Autoload () is called if the corresponding class does not exist when instantiating an object.

_ Invoke () when an object is called by calling a function, the __invoke method is automatically called.

4. MySQL statement for inserting fields into the database

Assume that our table name is users:

Alter table 'users' ADD 'uname' VARCHAR (200) not null after 'uid'; // ADD the uName field AFTER the uId field. The varchar 200 notnull in the middle is an attribute.

※The problem arises. What are the statements for deletion and modification?

Alter table 'users' DROP 'uname'; // Delete the uName Field

Alter table 'users' CHANGE 'uname' 'uid' INT (6) not null; // CHANGE the field uName to uId.

5. Differences between LAMP and LNMP

LAMP = Linux + Apache + Mysql + PHP
LNMP = Linux + Nginx + Mysql + PHP

Thanks to the woodpecker http://blog.sina.com.cn/s/blog_626998030102wofn.html

6. What are the HTTP request error return codes?

3xx: Redirection
301: moved-the requested data has a new location and the change is permanent. 302: Found-the requested data temporarily has different Uris.
303: see other-you can find the response to the request under another URI and use the GET method to retrieve the response.
304: not modified-the document was not modified as expected.
305: use proxy-the requested resource must be accessed through the proxy provided in the location field. 306: Not used-no longer used; keep this code for future use. 4xx: client errors
400: Incorrect request-the request has a syntax problem or cannot meet the request. 401: unauthorized-unauthorized client access to data. 402: payment required-the billing system is in effect. 403: forbidden-access is not required even if authorized.
404: No.-The server cannot find the specified resource. The document does not exist. 407: proxy authentication request-the client must first use proxy authentication itself.
415: the media type is not supported-the server rejects service requests because the Request Entity format is not supported. 5xx: Server Error
500: Internal error-the server cannot complete the request due to exceptions. 501: not executed-the server does not support the request tool.
502: Error gateway-the server receives an invalid response from the upstream server.
503: unable to obtain the service-the server cannot process the request due to temporary overload or maintenance. 900: Internal error (result generated when an exception is thrown during the program running) 901: Connection timeout 902: Response timeout 903: IO exception
904: Data exhaustion (data acquisition during parameterization) 905: Unknown host exception
906: URL protocol exception (url format error)
907: Certificate error (exceptions caused by certificate issues when using a local certificate during https requests) 908: socket connection error 910: IO exception interrupted 911: invalid status 912: unsupported operation 913: Connection closed
914: No http Response 915: Request aborted

※The problem arises again. What will be returned if the request is successful?

2xx: Successful
200: normal; the request has been completed. 201: normal; followed by the POST command.
202: normal; accepted for processing, but not completed. 203: normal; partial information-only part of the returned information.
204: normal; no response-received request, but no information to send back.

7. What are the differences between php versions?

8. Write asynchronous data transmission with JS Code?

9. Why should I add an index to a field? Which fields need to be indexed?

10. As I personally have some Linux system development experience, the interviewer asked me which linux commands I am familiar?

For more information, see http://www.runoob.com/linux/linux-command-manual.html.

Here are some common examples:

Change file permissions: chmod

Switch Directory: cd

Display the current directory: pwd

Create a new directory: mkdir

Delete an empty directory: rmdir

List the files and subdirectories contained in the current working directory: ls

Copy an archive or directory: cp

Name of the file in the returned path: basename

Directory in the returned path: dirname

Find a specific file: whereis locate find

 

 

 

To be continued ......

 

 

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.