Top 11 PHP questions with the highest frequency, and top 11 php questions

Source: Internet
Author: User

Top 11 PHP questions with the highest frequency, and top 11 php questions

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.

Prompt: 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 including 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.

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:

<A href = "javascript: document. myform. submit ();"> Submit Me </a>

Original article: Top PHP Job Interview Questions and Answers for 2014


Php interview questions


Which of the following statements will not add John to the users array?
$ Users [] = 'john ';
John is successfully added to the array users.
Array_add ($ users, 'john ');
The function array_add () is not defined.
Array_push ($ users, 'john ');
John is successfully added to the array users.
$ Users | = 'john ';
Syntax error.
2. What are the differences between sort (), assort (), and ksort? Under what circumstances are they used?
Sort ()
Sort the values of elements in the array in alphabetical order. The index key is numbered from 0 to n-1. It is mainly used to sort the array when the value of the array index key is irrelevant.
Assort ()
PHP does not have the assort () function, so it may be asort.
Asort ()
Like sort (), array elements are arranged in alphabetical order. The difference is that all index keys are retained, which is especially suitable for sorting Lenovo arrays.
Ksort ()
Sort the index key values in alphabetical order based on the index key values in the array. This is especially suitable for Lenovo arrays that want to sort the index key.
3. What will the following code generate? Why?
$ Num = 10;
Function multiply (){
$ Num = $ num * 10;
}
Multiply ();
Echo $ num;
Because the function multiply () does not specify $ num as a global variable (such as global $ num or $ _ GLOBALS ['num']), the value of $ num is 10.
4. What are the differences between reference and a regular variable? How to pass by reference? Under what circumstances do we need to do this?
Reference transmits the address of a variable rather than its value. Therefore, when you change the value of a variable in the function, the entire application will see the new value of this variable.
The value of a regular variable is transmitted to the function. When the function changes the value of this variable, only the function sees the new value, and the other part of the application still sees the old value.

$ MyVariable = "its 'value ";
Myfunction (& $ myVariable); // SEND Parameters Using reference to send Parameters to the function. variables changed by the function can be retained even after the function ends.
5. Which of the following functions can be used to insert a function library into the script being executed?
Different understandings of this question may have different answers. My first thought is to insert a PHP function library like include (), include_once (), require (), require_once (), but be careful, the "function library" should also include com objects and. net function library, so our answers should also include com_load and dotnet_load. When someone mentions the "function library", don't forget these two functions.
6. What are the differences between foo () and @ foo?
Foo () executes this function. Any interpretation errors, syntax errors, and execution errors are displayed on the page.
@ Foo () when executing this function, all the preceding error messages are hidden.
Many applications use @ mysql_connect () and @ mysql_query to hide mysql error messages. I think this is a serious mistake because errors should not be hidden and you must properly handle them, solve them if possible.
7. How do you detect errors for PHP applications?
I do not often do this. I have tried many different debugging tools and it is not easy to set these tools in Linux. However, I will introduce a debugging tool that has been quite noticed recently.
PHP ...... remaining full text>

Interview question: PHP

Bool ksort (array & array [, int sort_flags])
Sort the array by key name and retain the association between key names and data. This function is mainly used to associate arrays.
If the call succeeds, TRUE is returned. If the call fails, FALSE is returned.
Example:
<? Php
$ Fruits = array ("d" => "lemon", "a" => "orange", "B" => "banana ", "c" => "apple ");
Ksort ($ fruits );
Foreach ($ fruits as $ key => $ val ){
Echo "$ key = $ val \ n ";
}
?>
The above example will output:
A = orange
B = banana
C = apple
D = lemon

Bool asort (array & array [, int sort_flags])
This function sorts the array, and the index of the array remains associated with the unit. It is mainly used to sort the arrays that are very important to the unit order.
If the call succeeds, TRUE is returned. If the call fails, FALSE is returned.
Example
<? Php
$ Fruits = array ("d" => "lemon", "a" => "orange", "B" => "banana ", "c" => "apple ");
Asort ($ fruits );
Foreach ($ fruits as $ key => $ val ){
Echo "$ key = $ val \ n ";
}
?>
The above example will output:
C = apple
B = banana
D = lemon
A = orange

Bool sort (array & array [, int sort_flags])
This function sorts arrays. When the function ends, the group unit will be rescheduled from the lowest to the highest.
Note: This function assigns a new key name to the Unit in array. This will delete the original key name, not just the reorder.
If the call succeeds, TRUE is returned. If the call fails, FALSE is returned.
Example
<? Php
$ Fruits = array ("lemon", "orange", "banana", "apple ");
Sort ($ fruits );
Foreach ($ fruits as $ key => $ val ){
Echo "fruits [". $ key. "] =". $ val. "\ n ";
}
?>
The above example will output:
Fruits [0] = apple
Fruits [1] = banana
Fruits [2] = lemon
Fruits [3] = orange... remaining full text>

Related Article

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.