11 most frequently asked questions and answers in PHP, and php

Source: Internet
Author: User

11 most frequently asked questions and answers in PHP, and php

Are you looking for a PHP development job and some questions and answers about PHP? This article will share with you some of the 11 most frequently asked PHP interview questions and the corresponding regular answers. Each company has its own interview standards, interviews and questions depend entirely on the roles you play at work, and are also closely related to your programming skills.

Q: What is PHP in the simplest language?

A: PHP is short for Hypertext Preprocessor. It is a server scripting language used to develop dynamic websites.

Question: What is MVC?

A: MVC is composed of Model, View, and Controller. php mvc can manage PHP code on three different layers more efficiently.

Model: data information access layer.
View: The view layer displays application data in a specific way on the interface.
Controller: Generally, the Controller reads data from the view, controls user input, and sends data to the model.

Q: How can I reference CSS on a page?

A: There are three ways to use CSS on the page:
Reference external CSS files
Internally define Style styles
Inline Style

Q: Does PHP support multi-inheritance?

A: No. The PHP class can inherit only one parent class and is identified by the keyword "extended.

Q: What is the difference between echo and print in PHP?

These two seem very similar, because they all print some values on the screen. However, the essential difference between echo and print is that echo is used to output strings. When multiple values are displayed, they can be separated by commas. Only basic types are supported. print not only prints string values, but also prints the return values of functions.

Q: What is the difference between GET and POST methods?

A: The form information we enter on the web page can be transmitted to the server using these two methods. When we use the GET method, all the information will appear in the URL address, in addition, the GET method can only pass a maximum of 1024 characters, so you can use the GET method if the transmission volume is small or the security is not so important. The POST method can transmit up to 2 MB of data and can be adjusted as needed.

Q: How does PHP obtain the image size?

Answer: getimagesize () obtains the image size.
Imagesx () to get the Image Width
Imagesy () to get the Image Height

Q: What is PEAR in PHP?

A: PEAR is the PHP Extension and Application library (PHP Extension and Application Repository). It is a code Repository for PHP Extension and Application.

Q: How can I use PHP and MySQL to upload videos?

A: We can store video addresses in the database without having to store real video data in the database. You can store the video data in a specified folder on the server. The default size of the video to be uploaded is 2 MB, but you can also modify the max_file size Option in the php. ini file.

Q: What are the error types in PHP?

A: PHP has three types of errors.

Tip: these are some very normal information, not major errors, and some will not even be displayed to users. For example, access to a variable that does not exist.
Warning: this is a serious error. The warning information will be displayed to the user, but it will not affect the code output, such as containing some files that do not exist.
Error: this is a real serious error, such as accessing a PHP class that does not exist.

Q: How do I define constants in PHP?

A: Use Define () in PHP to Define constants.
Copy codeThe Code is as follows:
Define ("Newconstant", 30 );

Q: How do I not use the submit button to submit a form?

If we do not want to use the submit button to submit a form, we can also use a hyperlink to submit the form. We can write code like this:
Copy codeThe Code is as follows:
<A href = "javascript: document. myform. submit ();"> Submit Me </a>


PHP Programmer Computer interview questions (with answers attached, good answers plus points)

PHP interview questions for a large company

Management reminder: This post is canceled by haowubai)
1. How can I use the php environment variable to get the content of a webpage address? How can I get the IP address?
[Php]
Echo $ _ SERVER ['php _ SELF '];
Echo $ _ SERVER ['server _ ADDR '];
[/Php]

2. Calculate the difference between two dates, for example, 2007-2-5 ~ Date difference of-3-6
[Php]
$ Begin = strtotime ('2014-2-5 ');
$ End = strtotime ('2017-3-6 ');
Echo ($ end-$ begin)/(24*3600 );
[/Php]

3. Write a function to implement the following functions:
Convert the string "open_door" to "OpenDoor" and "make_by_id" to "MakeById ".
[Php]
Function changeStyle (& $ str ){

/* $ Str = str_replace ("_", "", $ str );
$ Str = ucwords ($ str );
$ Str = str_replace ("", "", $ str );
Return $ str ;*/

$ ArrStr = explode ('_', $ str );
Foreach ($ arrStr as $ key => $ value ){
$ ArrStr [$ key] = strtoupper (substr ($ value, 0, 1). substr ($ value, 1 );
}
Return implode ('', $ arrStr );
}
$ S = "open_door ";
Echo changeStyle ($ s );
[/Php]

4. Write a program to convert the following array $ arr1 into an array $ arr2:
[Php] $ arr1 = array (
'0' => array ('fid' => 1, 'tid' => 1, 'name' => 'name1 '),
'1' => array ('fid' => 1, 'tid' => 2, 'name' => 'name2 '),
'2' => array ('fid' => 1, 'tid' => 5, 'name' => 'name3 '),
'3' => array ('fid' => 1, 'tid' => 7, 'name' => 'name4 '),
'4' => array ('fid' => 3, 'tid' => 9, 'name' => 'name5 ')
);
$ Arr2 = array... the remaining full text>

Php Interview Questions and Answers, php pen questions

Principles and Applications of java exception Mechanism
A: If the program does not handle any exceptions, the program will be interrupted.
In fact, after an exception is generated, the JVM will throw an exception class instantiation object. If a try statement is used to capture the object at this time, the exception can be processed. Otherwise, the exception is handed over to the JVM for processing. When an exception is caught by a try statement, it matches the exception type of the catch statement. If the exception type matches successfully, the catch statement is executed. Simple Application: Add try-catch to the throws statement. Standard Application: try-catch-finally-throw-throws.
2. Advantages of the garbage collection mechanism
A: Release the space occupied by useless objects. Method: Automatic Recovery and manual recovery. Use System. gc () to actually call Runtime. getRuntime (). gc ()
3. Difference between Error and Exception
A: The Error is handled by jvm, and the Error is a jvm Error.
Exception can be handled by a program and captured using try-catch.
4. final, finally, finallize
A: The final defined variable values cannot be changed, the defined methods cannot be overwritten, And the defined classes cannot be inherited.
Finally is the unified exit of exceptions. finallize is the final work before garbage collection and is defined by the Object class.
5. Does Anonymous Inner Class support extends and implements Interface?
A: inheritance and implementation are allowed, because anonymous internal classes are developed based on abstract classes and interfaces.
6. Differences between Static Nested Class and Inner Class
A: The Class defined using Static is an external Class, which can be directly accessed through an external Class. Internal Class
Inner Class cannot be accessed externally. It can only be found through external Class instances.
7. HashMap and HashTable?
A: HashMap: 1) released in jdk 1.2, new Class 2) asynchronous processing, high performance, non-thread-safe 3) Allow null
HashTable: 1) released in jdk 1.0, old Class 2) adopts synchronous processing mode with low performance and is thread-safe. 3) null is not allowed.
8. What does assert mean?
A: asserts is a New Keyword released after jdk 1.4. asserts indicates assertions, that is, the execution of a program to a certain place must be an expected value, which is rarely used in development. To use assert, the-ea parameter must be added.
9. What is gc?
A: gc is a garbage collection. garbage collection can be used to release junk space.
10. How many objects are generated by String s = new String ("xyz?
A: An anonymous object xyz is in the stack space. A new instantiated object is in the heap space.
11. sleep () and wait ()?
A: sleep () is the Thread class definition method. It indicates the Thread sleep and can be automatically awakened.
The wait () method is defined by the Object class. You need to manually release y () and policyall () // sleep () without releasing resources. wait () releases resources.
12. goto exists in java, but it cannot be used.
13. Does the array have length () and String have length ()?
A: The array has the length attribute and the String has the length () attribute ()
14. Differences between Overload and Override
Answer: Overload: Heavy Load
|-Several methods defined in a class
|-All methods have the same name, but different parameter types or numbers
|-Only the parameters are related and the return type is irrelevant.
Overrid ...... the remaining full text>
 

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.