Home  >  Article  >  Backend Development  >  11 Most Frequently Asked PHP Interview Questions, Frequently Asked PHP Test Questions_PHP Tutorial

11 Most Frequently Asked PHP Interview Questions, Frequently Asked PHP Test Questions_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:17:59822browse

11 most frequently asked PHP interview questions, frequently asked PHP test questions

Are you preparing to find a PHP development job, and are also looking for some interviews about PHP Questions and answers? This article shares with you some of the 11 most frequently asked PHP interview questions, as well as the corresponding common answers. Each company has its own interview standards. The interview and questions completely depend on the role you play in the job. Of course It is also closely related to your programming skills.

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

<p>回答:PHP全称:Hypertext Preprocessor,是一种用来开发动态网站的服务器脚本语言。</p>

Question: What is MVC?

<p>回答:MVC由Model(模型), View(视图)和Controller(控制器)组成,PHP MVC可以更高效地管理好3个不同层的PHP代码。</p>
<p><strong>Model</strong>:数据信息存取层。</p>
<p><strong>View</strong>:view层负责将应用的数据以特定的方式展现在界面上。</p>
<p><strong>Controller</strong>:通常控制器负责从视图读取数据,控制用户输入,并向模型发送数据。</p>

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

<p>回答:在页面中使用CSS有3中方式:</p>
<ul>
<li>引用外部CSS文件</li>
<li>内部定义Style样式</li>
<li>内联样式</li>
</ul>

Question: Does PHP support multiple inheritance?

<p>回答:不可以。PHP类只能继承一个父类,并用关键字&ldquo;extended&rdquo;标识。</p>

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

<p>这两个看起来很相似,因为它们都是将一些值打印在屏幕上。但是echo和print的本质区别在于:echo用来输出字符串,显示多个值的时候可以用逗号隔开。只支持基本类型,print不仅可以打印字符串值,而且可以打印函数的返回值。</p>

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

<p>回答:我们再网页上填写的表单信息都可以通过这两个方法将数据传递到服务器上,当我们使用GET方法是,所有的信息都会出现在URL地址中,并且使用GET方法最多只能传递1024个字符,所以如果在传输量小或者安全性不那么重要的情况下可以使用GET方法。说到POST方法,最多可以传输2MB字节的数据,而且可以根据需要调节。</p>

Question: What is the method to get the image size in PHP?

<p>回答:getimagesize () 获取图片的尺寸</p>
<p>Imagesx () 获取图片的宽度</p>
<p>Imagesy () 获取图片的高度</p>

Question: What is PEAR in PHP?

<p>回答:PEAR也就是为PHP扩展与应用库(PHP Extension and Application Repository),它是一个PHP扩展及应用的一个代码仓库。</p>

Question: How to upload videos using PHP and MySQL?

<p>回答:我们可以在数据库中存放视频的地址,而不需要将真正的视频数据存在数据库中。可以将视频数据存放在服务器的指定文件夹下,上传的默认大小是2MB,但是我们也可以在php.ini文件中修改max_file size选项来改变。</p>

Question: What are the error types in PHP?

<p>回答:PHP中遇到的错误类型大致有3类。</p>
<p><strong>提示</strong>:这都是一些非常正常的信息,而非重大的错误,有些甚至不会展示给用户。比如访问不存在的变量。</p>
<p><strong>警告</strong>:这是有点严重的错误,将会把警告信息展示给用户,但不会影响代码的输出,比如包含一些不存在的文件。</p>
<p><strong>错误</strong>:这是真正的严重错误,比如访问不存在的PHP类。</p>

Question: How to define constants in PHP?

<p>回答:PHP中使用Define () 来定义常量。</p>
<p>define (&ldquo;Newconstant&rdquo;, 30);</p>

Question: How to submit a form without using the submit button?

<p>如果我们不想用submit按钮来提交表单,我们也可以用超链接来提交,我们可以这样写代码:</p>
<p><a href=&rdquo;javascript: document.myform.submit();&rdquo;>Submit Me</a></p>

 Original text: Top PHP Job Interview Questions and Answers for 2014 Translation: codeceo – Xiaofeng

php interview questions


Which of the following sentences will not add John to the users array?
$users[] = 'john';
Successfully added John to the users array.
array_add($users,’john’);
Function array_add() has no definition.
array_push($users,‘john’);
Successfully added John 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 in English alphabetical order according to the value of the elements in the array, and the index keys will be renumbered from 0 to n-1. Mainly used to sort the array when the value of the array index key is irrelevant.
assort()
PHP does not have assort() function, so it may be a typo in asort().
asort()
Like sort(), it arranges the elements of the array in English alphabetical order. The difference is that all index keys are retained, which is especially suitable for sorting associative arrays.
ksort()
Sort in English alphabetical order according to the value of the index key in the array. It is especially suitable for associative arrays that want to sort the index keys.
3. What will the following code produce? Why?
$num =10;
function multiply(){
$num =$num *10;
}
multiply();
echo $num;
Due to function The formula multiply() does not specify $num as a global variable (such as global $num or $_GLOBALS['num']), so the value of $num is 10.
4. What is the difference between a reference and a regular variable? How to pass by reference? Under what circumstances do we need to do this?
Reference passes the address of the variable rather than its value, so when the value of a variable is changed in a function, the entire application sees the new value of the variable.
What a regular variable passes to a function is its value. When the function changes the value of this variable, only this function sees the new value, and other parts of the application still see the old value.

$myVariable = "its' value";
Myfunction(&$myVariable); // Pass parameters by reference. Pass parameters by reference to the function, so that the variables changed by the function can be changed even after The new value is retained after the function ends.
5. What functions can be used to insert function libraries into the currently executing script?
Different understandings of this question will lead to different answers. My first idea is to insert the PHP function library, which is nothing more than include(), include_once(), require(), require_once(), but be careful. Think about it, "function library" should also include com objects and .net function libraries, so our answer should also include com_load and dotnet_load respectively. Next time someone mentions "function library", don't forget these two functions. .
6. What is the difference between foo() and @foo()?
foo() will execute this function, and any interpretation errors, syntax errors, and execution errors will be displayed on the page.
@foo() will hide all the above error messages when executing this function.
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. You must handle them properly and resolve them if possible.
7. How do you debug PHP applications?
I don't do this often, I've tried a lot of different debugging tools and setting them up on a Linux system is not easy at all. But below I will introduce a debugging tool that has attracted much attention recently.
PHP...the rest of the text>>

Interview question solution: PHP

bool ksort ( array &array [, int sort_flags] )
Sort the array by key name and retain the association between key name and data. This function is mainly used for associative arrays.
Returns TRUE if successful, FALSE if failed.
Example:
733c86513fdfe2b1334bdbec05703764"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. Mainly used for sorting associative arrays where the order of cells is important.
Returns TRUE if successful, FALSE if failed.
Example
95d394caa6309e520f8177f2774c90f6 "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 the array. When this function ends the array cells will be rearranged from lowest to highest.
Note: This function assigns new key names to the cells in array. This will delete the original keys rather than just reorder them.
Returns TRUE if successful, FALSE if failed.
Example
42150597ac306e52d4f7ec222a6047e2 $val) {
echo "fruits[".$key."] = " . $val . "\n";
}
?>
The above example will output:
fruits[0] = apple
fruits[1] = banana
fruits[2] = lemon
fruits[3] = orange... The rest of the text>>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/887098.htmlTechArticle11 Most Frequently Asked PHP Interview Questions, Frequently Asked PHP Test Questions Are you preparing to find a job in PHP development? Are you working and looking for some interview questions and answers about PHP? This article is...
Statement:
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