$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 ."It's a pity that there is no fate";
}
echo is_gfriend(a,b);
?>
Copy code
4,
Company interview questions: Baidu web development engineer written test questions】
Part one:
1. Explain the meaning of the following statement: document.form["formname"].submit;
2. There are the following statements:
Write code so that when the mouse moves over the text box, the content in the text box is automatically selected.
3. Convert character 09 into decimal number.
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.
Both html and javaservlet are required to be written.
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 Scripting School bbs.it-home.org)
Answer: 1. Get the formname form submit button element.
8. Analysis from 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);
When executing the following query, the speed is always very slow:
select * from product where price=100;
Adding a non-clustered index to the price field, the query speed is still very slow.
(1) Analyze the reasons for slow query.
(2) How to optimize. 5.
create table topid{
topicid int not null primary key auto_increment,
title text,
author varchar(30),
content blob,
isdeleted int
...... //It seems 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
..../ / Define an index and key
}
Copy the code
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. Query the topics whose reply time does not exceed a specific time period and the author's name of the reply starts with mike
title, query as follows: (Edited and compiled by Programmer’s Home bbs.it-home.org)
select * from topic where replyid in (select replyid from reply where
replyauthor like 'mike%' and (currenttime()-replytime
Copy code
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.
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