Home  >  Article  >  php教程  >  PHP classic interview questions and answers (referred to Pioneer Tutorial Network)

PHP classic interview questions and answers (referred to Pioneer Tutorial Network)

WBOY
WBOYOriginal
2016-09-09 08:13:331296browse

php classic interview questions and answers

Time: 2016-02-29 16:06:23 Source: Internet
Introduction: PHP classic interview questions and answers, including Tencent PHP interview questions, Baidu PHP interview questions, Sina PHP interview questions, etc.
php interview questions and answers

1. Can Seesion still work after disabling cookies?
2. What function would you use to capture remote images locally?
3. Given name a and name b, give an algorithm to find their fate
4. Do you think Lunix is ​​much faster than Win in pv10w with the same configuration?
5. Briefly describe the maximum capacity of post and get transmission respectively?
6. Write a function to find the maximum of 3 values ​​with the least code.

Answer: 1. Cookies are stored locally, while seesion is stored on the server. Therefore, there is no direct relationship between the two. Seesion can still be used after disabling cookies.

2. Use file_get_contents function, ex:

Copy codeCode example:
$img = file_get_contents('http://www.xfcodes.com/ img/baidu_logo.gif');
file_put_contents('1.gif',$img);
echo '';
?>

3、

Copy codeCode example:

function is_gfriend($na,$nb)
{
        $random1=rand(1,5);//Calculate that they have 1/5 fate
$random2=rand(1,5);
if ($random1==$random2)
return $na."+".$nb."You are destined";
else
return $na."+".$nb."Unfortunately there is no fate";

}
echo is_gfriend(a,b);
?>

4,

Company interview questions: Baidu web development engineer written test questions】

Part 1:
1. Explain the meaning of the following statement: document.form["formname"].submit;

2. There is the following statement:

Write code. When the mouse moves over the text box, the content in the text box will be automatically selected.

3. Convert character 09 into decimal number. www.xfcodes.com

4. Convert 1234567890 into 1,234,567,890 by separating every 3 digits with commas.

5. I forgot about html and css.

6. Enter a year in the text box, determine its zodiac sign, and output it next to the text box.
Required to write both html and javaservlet.

7.ajax retrieves data from the server {id: 123, name: "baidu", username: "mm", checked: true};
Analyze the value corresponding to name ("baidu"). (The question is long, I can’t remember )

8. Talk about customer experience. (Edited and compiled by Script Academy www.jbxue.com)

Answer: 1. Get the formname form submit button element.

2,

Copy codeCode example:

3,

Copy codeCode example:
$a="09";
echo ( int ) $a;
echo "
";
echo intval("09");
?>

4,

Copy codeCode example:
$num = preg_replace('/(?<=[0-9])(?=(?:[0-9]{3})+(?! [0-9]))/', ',', $num);
echo $num; ?>

6,

Copy codeCode example:
$t= 1986;
switch ($t)
{
case 1986:
echo "cow";
break;
case "":
break;
case "":
break;
...
}

8. Analyze from the perspective of satisfaction, tolerance, and feedback.

Part 2:

1. Common ideas of ajax, database trigger, gui, and interrupt mechanism. Let’s talk about this idea (mechanism).

2. Convert the first letters of all words in an English document to uppercase, and the document is stored in doc.txt. You can choose from a variety of programming languages ​​​​(cc++, java, php...) to write out your ideas and try to optimize your program.

3. About the data structure of tree.

4. Database optimization:
There is a table product(id, name, price, count);
The speed is always very slow when executing the query:
select * from product where price=100;
Add to the price field With the previous non-clustered index, the query speed was still very slow.
(1) Analyze the reasons for slow query.
(2) How to optimize.

5.

Copy codeCode example:
create table topid{
topicid int not null primary key auto_increment,
title text,
author varchar(30),
content blob,
isdeleted int
... //It seems that an index is defined on author
}
create table reply{
topicid int foreign key,
replyid int primary key auto_increment,
replyauthor varchar(30),
replytime datetime,
context blob
.... //An index and key are defined
}

One is the topic table and the other is the reply table.

1. Ask what are the shortcomings of doing this in terms of performance.
2. If the query reply time does not exceed a specific time period, the title of the topic
whose author’s name starts with mike should be queried as follows: (Edited by Script Academy www.jbxue.com)

Copy codeCode example:
select * from topic where replyid in (select replyid from reply where
replyauthor like 'mike%' and (currenttime()-replytime

What are the shortcomings of the above query statement in terms of performance?
How to optimize?

Answer: 1. The database trigger and interrupt mechanism are automatically completed by the database, while the ajax trigger is triggered by the user. Ajax optimizes the GUI and the database asynchronously.

2、

Copy codeCode example:
$fp=fopen("aa.txt",'r'); //English document aa.txt
while(!feof($fp)){
$char=fgets($fp);
}
$e= explode(",",$char);
$write=fopen("doc.txt",'w');//If there is no doc.txt, create
foreach ($e as $w)
{
if($w==$e[count($e)-1])//Enter the last word without a comma if($w==end($e))
$w=ucwords($w) ;//Convert the first letter to uppercase
else
$w=ucwords($w).",";
echo $w;
fwrite($write,$w);//Write into the doc.txt document
}
fclose($write);
fclose($fp);
?>

Articles you may be interested in:

  • Tencent PHP programmer interview questions focus on the use of PHP magic methods
  • Tencent PHP interview questions and answers
  • Tencent PHP programmer interview questions, Q&A PHP interview questions
  • The latest Tencent PHP interview questions, high-tech PHP interview questions
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