Today's pen exam

Source: Internet
Author: User
This post is edited by bing15 at 18:13:37 on.

1. in a single order system shopping, the system may be slow due to the slow network, resulting in the customer repeatedly click to submit, what is a good solution.

2. in a one-dimensional array, the data type is integer, and the bubble sorting algorithm is used to sort data from small to large.

3. if you have used transaction processing, write at least three functions for transaction processing.

4. traverse all the files and subfolders in a folder.



Reply to discussion (solution)

1. click the button to make it unavailable. the prompt is "submitting...". it will be restored after the result is returned.

2. Omitted

3. never used ..

4... this is really useless.

Khan's interview schedule

They are all basic questions and there is nothing to say.
1. click the submit button once and set it to Gray (not available). after several seconds (or the corresponding callback function), it will not only prevent repeated submission, it also prevents the impact on the server caused by a large number of repeated submissions.

4. recursive processing. Note that in a linux system, you must avoid repeated loop searches for directories such as. and.

No one writes the second one, so I will write the second one.

Function maopao ($ arr) {$ len = count ($ arr); for ($ I = 1; $ I <$ len; $ I ++) // Do n-1 sort at most {$ flag = false; // The swap flag should be false for ($ j = $ len-1; $ j >=$ I; $ j --) {if ($ arr [$ j] <$ arr [$ j-1]) // exchange records {// if it is from large to small, just change the judgment here to if ($ arr [$ j]> $ arr [$ j-1]) $ x = $ arr [$ j]; $ arr [$ j] = $ arr [$ j-1]; $ arr [$ j-1] = $ x; $ flag = true; // exchange occurred, therefore, set the switch flag to true} if (! $ Flag) // The return $ arr;} $ shuz = array ('2', '4', '1 ', '8', '5'); $ bb = maopao ($ shuz); print_r ($ bb );

It suits me and I like it.

3. several points of transaction processing
First, the data engine is innoDB

Transaction processing is to put together a bunch of SQL commands for execution. If all SQL statements are successfully executed, this transaction is successful and can be submitted.
If an SQL command fails, this transaction fails. Therefore, you can call the rollback method to cancel all the preceding operations;

Transaction processing process
Start things first
Set autocommit = 0;
.....
SQL
....
If (true)
Commit ();
Else
Rollback ();

Function travelPath (& $ fileItem, $ path ){
If (file_exists ($ path )){
If (is_dir ($ path )){
If ($ handle = opendir ($ path )){
Foreach ($ item as $ handle ){
If ($ item = '.' | $ item = '..')
Return;
If (! Is_dir ($ item )){
$ FileItem [] = $ item;
Return;
}

TravelPath ($ fileItem, $ item );
}
}
}
}
}

It suits me and I like it.

1. click the button to make it unavailable. the prompt is "submitting...". it will be restored after the result is returned.

2. Omitted

3. never used ..

4... this is really useless.

Khan's interview schedule
It is said that the network is slow and is being submitted. Not displayed when submitting.

I think form tokens are used. This prevents repeated submission.

I think form tokens are used. This prevents repeated submission.

So what information will be sent to users during the long wait? No response? It's really better to say this. I clicked it and changed it to "submitting...". then I submitted it. then I received the result and changed it back.

Are php interviews all like this? I want to learn more!


I think form tokens are used. This prevents repeated submission.

So what information will be sent to users during the long wait? No response? It's really better to say this. I clicked it and changed it to "submitting...". then I submitted it. then I received the result and changed it back.
What I'm talking about is that we can really block repeated submissions, but you are not necessarily. if the network doesn't work, the form page won't change, and naturally won't be submitted freely. Besides, if you say that you use JS to change, I will tell you how if no one has submitted JS, can someone submit it all the time, right? Do not say that the user will not do this. I will tell you what if the hacker does this?



I think form tokens are used. This prevents repeated submission.

So what information will be sent to users during the long wait? No response? It's really better to say this. I clicked it and changed it to "submitting...". then I submitted it. then I received the result and changed it back.
What I'm talking about is that we can really block repeated submissions, but you are not necessarily. if the network doesn't work, the form page won't change, and naturally won't be submitted freely. Besides, if you say that you use JS to change, I will tell you how if no one has submitted JS, can someone submit it all the time, right? Do not say that the user will not do this. I will tell you what if the hacker does this?

Form tokens are useful. however, please note that the landlord's condition "slow network leads to multiple submissions". In this case, the form token may not be matched or invalid, and the user has already clicked the submit button multiple times, therefore, it is more appropriate to use JS for control.
In addition, the two do not conflict with each other and can be used.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.