Home > Backend Development > PHP Tutorial > 10 PHP interview questions commonly used in IT company interviews in spring 2019!

10 PHP interview questions commonly used in IT company interviews in spring 2019!

云罗郡主
Release: 2023-04-05 09:12:01
Original
8324 people have browsed it

Today, the editor of php Chinese website accidentally heard the interview questions on the road, so on a whim, I compiled 10 frequently asked questions in php interviews. If you have time, you can take a look.

Related recommendations: 2019 PHP interview questions summary (collection)

1. Which network protocol does nginx use?

Answer: nginx is the application layer. I think from bottom to top, the transport layer uses tcp/ip, the application layer uses http, and fastcgi is responsible for scheduling the process!

2.eho ,The difference between print and print_r?

Answer: echo is a language structure with no return value; print function is basically the same as echo, except that print is a function with return value; print_r is recursive printing. Used to output array objects.

3.What are the features of PHP?

Answer: ①.php uniquely mixes C, Java, Prel and PHP’s own syntax.

②. It can execute dynamic web pages faster than CGI or Prel. Compared with other programming languages, PHP embeds the program into the HTML document for execution. The execution efficiency is much higher than CGI that completely generates HTML editing. All CGI can be realized.

③.Supports almost all popular databases and operating systems.

④.PHP can use C and C for program expansion.

4. Find the subscript of the maximum number in the array?

Answer: 1.functionmaxkey($arr){

2.$maxval=max($arr);3. foreach($arras$key=>$val){4.if($maxval==$val){5.$maxkey=$key;6.}7.}8.return$maxkey;9.}

10.$arr=array(0,-1,-2,5,"b"=>15,3);11.echomaxkey($arr);

Output: b

5. For websites with large traffic, what method do you use to solve the traffic problem?

Answer: ①. Use cache effectively to increase cache hit rate.

②.Use load balancing.

③.Use CDN to store and accelerate static files.

④.Ideas to reduce the use of database.

⑤ .Check where the bottlenecks of statistics are.

6.Talk about the advantages and disadvantages of asp, php, jsp?

Answer: ①asp needs to rely on IIS, which is Microsoft Development language

②.php and jsp can rely on other servers such as apache or nginx

7. Briefly describe two methods of shielding notice warnings of PHP programs?

Answer: Initialize variables, set the error level at the beginning of the file or modify php.ini to set error_reportingset_error_handler and @Suppress errors:

①Add: error_reporting(E_ALL&~E_NOTICE);②.Or modify Change: error_reporting=E_ALL in php.ini to: error_reporting=E_ALL&~E_NOTICE③.error_reporting(0); or modify php.inidisplay_errors=Off

8. Which of the following options does not add john to users In the array?(B)

(A)$users='john';(B)array_add($users,'john');(C)array_push($users,'john') ;(D)$users||='john';

9. Write a function to extract the file extension from a standard URL as efficiently as possible?

Answer: For example, ://www.sina.com.cn/abc/de/fg.php?id=1 need to remove php or .php?

$url="//www.sina.com.cn/abc/de/fg.php?id=1";
arr=parseurl(url);
pathArr=pathinfo(arr['path']);
print_r($pathArr['extension']);
Copy after login

10. Write a function , can it traverse all files and subfolders under a folder?

Answer: As follows.

functionaGetAllFile($folder)
{
$aFileArr=array;
if(is_dir($folder))
{
handle=opendir(folder);
while((file=readdir(handle))!==false)
{
//如果是.或者..则跳过
if(file=="."||file=="..")
{
continue;
}
if(is_file(folder."/".file))
{
aFileArr=file;
}
elseif(is_dir(folder."/".file))
{
aFileArr[file]=aGetAllFile(folder."/".file);
}
}
closedir($handle);
}
return$aFileArr;
}
$path="/home/test/sql";
Copy after login

The above is the detailed content of 10 PHP interview questions commonly used in IT company interviews in spring 2019!. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template