Home  >  Article  >  Backend Development  >  如何后台执行某段程序?

如何后台执行某段程序?

WBOY
WBOYOriginal
2016-06-23 13:16:07681browse

各位大神,用户进入1.php页面后,执行两段程序A和B,因为A的执行时间比较长,对后续操作无影响;而B程序比较简单,且执行后会跳转到2.php,我希望实现在用户进入1.php后,就先执行B程序,然后跳转到2.php;但同时后台继续执行A程序直到处理完毕。是否能实现?谢谢各位大神!


回复讨论(解决方案)

1、php多线程
2、php伪线程
3、ajax异步

第一种,第二种百度以下就知道了,其中第一种比较费事,原理就是分出不同的线程或者进程同事访问这两个代码段,通过返回值进行跳转

B;
header('location: 2.php');
A;

谢谢两位大神,但思路为什么差异这么大呢?我看得懂xuzuning的思路,单不知道xuzuning,您的方案,能确保A程序能执行,且不影响我执行B程序和跳转到2.php?再次感谢!!!

谢谢两位老师!!!

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