11 Most frequently asked PHP interview questions, question frequency php question _php tutorial

Source: Internet
Author: User
Tags pear php and mysql what php

11 Most frequently asked PHP interview questions, question frequency PHP questions


Are you looking for a PHP development job, and are you looking for some questions and answers about PHP? This article shares some of the 11 most frequently asked PHP interview questions, as well as the corresponding regular answers, each company has its own interview criteria, interviews and questions are entirely dependent on your role in the work, of course, and your programming skills are closely related.

Question: Please tell me in the simplest language what PHP is?

Answer: PHP full name: Hypertext preprocessor, is a server scripting language used to develop dynamic Web sites.

Question: What is MVC?

Answer: MVC consists of model, view, and controller, and PHP MVC can manage 3 different layers of PHP code more effectively.

Model: Data information access layer.

View: The view layer is responsible for presenting the applied data to the interface in a specific way.

Controller: It is common for controllers to read data from the view, control user input, and send data to the model.

Question: Are there several ways to reference CSS in a page?

Answer: There are 3 ways to use CSS in the page:

  • referencing external CSS files
  • Internally defined style style
  • inline style

Question: Does PHP support multiple inheritance?

Answer: No, you can't. The PHP class can inherit only one parent class and is identified with the keyword "extended".

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

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

Question: What is the difference between the Get and post methods?

Answer: The form information that we fill out on the webpage can pass the data to the server through these two methods, when we use Get method is, all information will appear in the URL address, and use Get method can only pass 1024 characters, Therefore, you can use the Get method if the transfer volume is small or the security is less important. When it comes to the post method, you can transfer up to 2MB bytes of data and adjust it as needed.

Question: What is the way to get the size of an image in PHP?

Answer: getimagesize () Get the size of the picture

Imagesx () Get the width of the picture

Imagesy () Get the height of the picture

Question: What is pear in PHP?

Answer: Pear is the PHP extension and application Library (PHP Extension and Application Repository), which is a code repository for PHP extensions and applications.

Question: How do I upload videos in PHP and MySQL?

Answer: We can store the address of the video in the database without having to have the real video data in the database. The video data can be stored in the server's specified folder, the default size of the upload is 2MB, but we can also modify the max_file size option in the php.ini file to change.

Question: What are the types of errors in PHP?

Answer: There are roughly 3 types of errors encountered in PHP.

Tip : It's all very normal information, not a big mistake, and some won't even show it to the user. For example, access to non-existent variables.

warning : This is a bit of a serious error that will present the warning message to the user, but will not affect the output of the code, such as containing some files that do not exist.

Error : This is a real serious error, such as accessing a nonexistent PHP class.

Question: How do I define Constants in PHP?

Answer: PHP uses define () to define constants.

Define ("Newconstant", 30);

Question: How do I submit a form without using the Submit button?

If we do not want to submit the form with the Submit button, we can also use hyperlinks to submit, we can write the code:

Submit Me

Original: Top PHP Job interview Questions and Answers for 2014 translations: codeceo– Xiao Feng


PHP face Test


Which of the following sentences does not add John to the users array?
$users [] = ' John ';
John was successfully added to the array users.
Array_add ($users, ' John ');
There is no definition for function array_add ().
Array_push ($users, ' John ');
John was successfully added to the array users.
$users | | = ' John ';
Syntax error.
What are the differences between 2.sort (), Assort (), and Ksort ()? Under what circumstances are they used?
Sort ()
The index keys are renumbered from 0 to n-1 based on the values of the elements in the array, sorted in alphabetical order. It is mainly used to sort the array when the value of the array index key is unrelated to the itch.
Assort ()
PHP does not have a assort () function, so it may be a clerical error for asort ().
Asort ()
As with sort (), the elements of the array are arranged alphabetically, but all index keys are preserved, especially for associative arrays.
Ksort ()
Based on the values of the index keys in the array, the alphabetical order is especially suitable for associative arrays that want to sort the index keys.
3. What does the following code produce? Why?
$num = 10;
function Multiply () {
$num = $num *10;
}
Multiply ();
Echo $num;
The value of the $num is 10 because the function multiply () does not specify $num to be a global variable (for example, $num or $_globals[' num ').
4. What is the difference between a reference and a regular variable? How do I pass by reference? Under what circumstances do we need to do this?
The Reference transmits the address of the variable instead of its value, so when you change the value of a variable in a function, the entire application sees the new value of the variable.
A regular variable is passed to its value, and when the function changes the value of the 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); Transfer parameters with reference to reference transfer parameters to the function, you can make the function changes the variable, even after the function ends still retain the new value.
5. Some functions can be used to insert a function library in a script that is currently executing?
There are different answers to this question, and my first idea is to insert the PHP function library into the include (), include_once (), require (), require_once (), but think carefully again that the function library should also include COM objects and. NET function library, so our answer is to include com_load and Dotnet_load, and the next time someone mentions a "library", don't forget the two functions.
What is the difference between 6.foo () and @foo ()?
Foo () executes the function, and any interpretation errors, syntax errors, and execution errors will be displayed on the page.
@foo () will hide all of the above error messages when executing this function.
Many applications use @mysql_connect () and @mysql_query to hide MySQL error messages, which I think is a serious mistake, because mistakes shouldn't be hidden, you have to deal with them properly, and you can solve them if possible.
7. How do you debug your PHP application?
I don't often do this, I've tried many different debugging tools, and it's not easy to set up these tools in a Linux system. However, I will introduce a recently-noticed debugger.
Php...... Remaining full text >>

Job Interview: PHP

BOOL Ksort (array &array [, int sort_flags])
The array is sorted by key name, preserving the association of the key name to the data. This function is mainly used for associative arrays.
Returns TRUE if successful, and FALSE if it fails.
Example:
$fruits = Array ("d" = "lemon", "a" and "Orange", "b" = "banana", "c" = "apple");
Ksort ($fruits);
foreach ($fruits as $key = = $val) {
echo "$key = $val \ n";
}
?>
The example above will output:
A = Orange
b = Banana
c = Apple
D = Lemon

BOOL Asort (array &array [, int sort_flags])
This function sorts the arrays, the index of the array remains, and the cell is associated. It is primarily used to sort the associative arrays that are important for the cell order.
Returns TRUE if successful, and FALSE if it fails.
Example
$fruits = Array ("d" = "lemon", "a" and "Orange", "b" = "banana", "c" = "apple");
Asort ($fruits);
foreach ($fruits as $key = = $val) {
echo "$key = $val \ n";
}
?>
The example above will output:
c = Apple
b = Banana
D = Lemon
A = Orange

BOOL Sort (array &array [, int sort_flags])
This function sorts the array. When this function ends, the array cell is rescheduled from lowest to highest.
Note: This function assigns a new key name to the cells in the array. This will delete the original key name and not just reorder it.
Returns TRUE if successful, and FALSE if it fails.
Example
$fruits = Array ("Lemon", "orange", "banana", "apple");
Sort ($fruits);
foreach ($fruits as $key = = $val) {
echo "fruits[". $key. "] = " . $val. "\ n";
}
?>
The example above will output:
Fruits[0] = Apple
FRUITS[1] = Banana
FRUITS[2] = Lemon
FRUITS[3] = orange ... Remaining full text >>

http://www.bkjia.com/PHPjc/887098.html www.bkjia.com true http://www.bkjia.com/PHPjc/887098.html techarticle 11 Most frequently asked PHP interview questions, question frequency PHP questions are you looking for a PHP development job, and are you looking for some questions and answers about PHP? This article is for ...

  • 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.