The 11 most frequently asked interview questions and answers in PHP

  • 2021-07-16 02:01:07
  • OfStack

Are you looking for a job in PHP development, and are you also looking for some interview questions and answers about PHP? This article shares one 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 your role in the job, and of course they are closely related to your programming skills.

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

Answer: PHP full name: Hypertext Preprocessor, is a kind of server scripting language used to develop dynamic website.

Question: What is MVC?

Answer: MVC consists of Model (model), View (view) and Controller (controller), and PHP MVC can manage PHP code of three different layers more efficiently.

Model: Data information access layer.
View: The view layer is responsible for presenting the data of the application in a specific way on the interface.
Controller: Normally the controller is responsible for reading data from the view, controlling user input, and sending data to the model.

Question: How many ways are there to reference CSS in a page?

Answer: There are three ways to use CSS in a page:
Referencing an external CSS file
Internal definition of Style style
Inline style

Question: Does PHP support multiple inheritance?

Answer: No. 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 both print 1 values on the screen. However, the essential difference between echo and print is that echo is used to output strings, and multiple values can be separated by commas. Supporting only primitive types, print prints not only string values, but also the return values of functions.

Question: What is the difference between GET and POST?

Answer: The form information we fill out on the web page can pass the data to the server in these two methods. When we use the GET method, all the information will appear in the URL address, and the GET method can only pass 1024 characters at most, so we can use the GET method if the transmission volume is small or the security is not so important. When it comes to the POST method, you can transfer up to 2MB bytes of data, and it can be adjusted as needed.

Question: What is the method of obtaining image size in PHP?

Answer: getimagesize () gets the size of the picture
Imagesx () Gets the width of the picture
Imagesy () Gets the height of the picture

Question: What is PEAR in PHP?

Answer: PEAR is also the PHP Extension and Application Library (PHP Extension and Application Repository), which is a code warehouse for an PHP extension and application.

Question: How to upload video with PHP and MySQL?

Answer: We can store the video address in the database without having to store the real video data in the database. The video data can be stored in a specified folder on the server, and the default upload size is 2MB, but we can also change it by modifying the max_file size option in the php. ini file.

Question: What are the types of errors in PHP?

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

Tip: This is all very normal information, not a major error, and some of it will not even be displayed to the user. Such as accessing variables that do not exist.
Warning: This is a serious error and will present a warning message to the user, but it will not affect the output of the code, such as including 1 file that does not exist.
Error: This is a really serious error, such as accessing the non-existent PHP class.

Question: How do I define constants in PHP?

Answer: Define () is used in PHP to define constants.


define ( " Newconstant " , 30);

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

If we don't want to use the submit button to submit the form, we can also use the hyperlink to submit it. We can write the code like this:


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


Related articles: