Table of Contents
回复讨论(解决方案)

今天的笔试题

Jun 23, 2016 pm 02:19 PM

本帖最后由 bing15 于 2013-08-05 18:13:37 编辑

1.在一个订单系统购物中,系统可能会因为网络比较慢,造成客户多次点击提交,有什么好的解决方案。

2.在一维的数组中,数据类型是整型,使用冒泡排序算法进行从小到大的排序。

3.你是否使用过事务处理,请最少写出3个事务处理的函数。

4.请遍历出一个文件夹下的所有文件及子文件夹的函数。



回复讨论(解决方案)

1.点击后先使按钮不可点,提示:"正在提交...",直到返回结果后再恢复.

2.略

3.没用过..

4. ....这个真没用过

汗 面试不上的节奏

都是比较基础的题,没什么太多可说的。
1. 点击一次提交后 提交按钮置灰(不可点),几秒后恢复(或者相应的回调函数),不仅可以防止重复提交,而且防止由于大量重复提交对服务器的冲击。

4. 递归处理之。需要注意的是如果是linux系统,要避免对. 和.. 目录的重复循环搜索。

没人写第二个,那我就写第二个吧

function maopao($arr){ $len = count($arr); for($i=1; $i<$len; $i++)//最多做n-1趟排序 {  $flag = false;    //本趟排序开始前,交换标志应为假  for($j=$len-1;$j>=$i;$j--)  {   if($arr[$j]<$arr[$j-1])//交换记录   {//如果是从大到小的话,只要在这里的判断改成if($arr[$j]>$arr[$j-1])就可以了     $x=$arr[$j];     $arr[$j]=$arr[$j-1];     $arr[$j-1]=$x;     $flag = true;//发生了交换,故将交换标志置为真   }  }  if(! $flag)//本趟排序未发生交换,提前终止算法  return $arr;    }}$shuz = array('2','4','1','8','5');$bb = maopao($shuz);print_r($bb);
Copy after login

适合我的水平,我喜欢。

3.事物处理几个点
首先数据引擎要是innoDB

事物处理就是把一堆sql命令放到一起来执行,所有sql语句都执行成功,那么这次事物就是成功的,就可以提交了
如果有sql命令没有成功,那么这次事物就是失败的,所以可以调用rollback方法把前面的操作全部撤销;

事物处理的过程
首先开启事物
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);
}
}
}
}
}

适合我的水平,我喜欢。

1.点击后先使按钮不可点,提示:"正在提交...",直到返回结果后再恢复.

2.略

3.没用过..

4. ....这个真没用过

汗 面试不上的节奏
人家都说网络慢了,还正在提交。正在提交都不显示。

我觉得用表单令牌。可以阻止重复提交。

我觉得用表单令牌。可以阻止重复提交。

那在漫长的等待过程中给用户传达什么信息呢? 再点没反应? 还真不如我说这个,点了先改成"正在提交中..."然后去提交,收到结果再改回来

php面试都要这样吗?那我还是再学学吧!


我觉得用表单令牌。可以阻止重复提交。

那在漫长的等待过程中给用户传达什么信息呢? 再点没反应? 还真不如我说这个,点了先改成"正在提交中..."然后去提交,收到结果再改回来
我说的是能真在的阻止重复提交,而你的不一定,如果网络不通的话,表单的页面是不会变的,自然也不会改在自在提交。再说,如果你说你用的是JS变的,那我告诉你如果没人把JS去了怎么样,人家可以一直提交对不对?你不要说用户不会这么做,那我告诉你如果是黑客这么做你怎么办?



我觉得用表单令牌。可以阻止重复提交。

那在漫长的等待过程中给用户传达什么信息呢? 再点没反应? 还真不如我说这个,点了先改成"正在提交中..."然后去提交,收到结果再改回来
我说的是能真在的阻止重复提交,而你的不一定,如果网络不通的话,表单的页面是不会变的,自然也不会改在自在提交。再说,如果你说你用的是JS变的,那我告诉你如果没人把JS去了怎么样,人家可以一直提交对不对?你不要说用户不会这么做,那我告诉你如果是黑客这么做你怎么办?

表单令牌是有用的.但是请注意楼主的条件" 网络比较慢造成多次提交",这种情况下,可能表单令牌还没有进行匹配和失效,用户就已经多次点击提交按钮了,所以用JS来控制比较合适.
而且,这两者并不冲突 可以都用.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log Analysis PHP Logging: Best Practices for PHP Log Analysis Mar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

HTTP Method Verification in Laravel HTTP Method Verification in Laravel Mar 05, 2025 pm 04:14 PM

Laravel simplifies HTTP verb handling in incoming requests, streamlining diverse operation management within your applications. The method() and isMethod() methods efficiently identify and validate request types. This feature is crucial for building

Discover File Downloads in Laravel with Storage::download Discover File Downloads in Laravel with Storage::download Mar 06, 2025 am 02:22 AM

The Storage::download method of the Laravel framework provides a concise API for safely handling file downloads while managing abstractions of file storage. Here is an example of using Storage::download() in the example controller:

See all articles