這一直是一個很難搜索的問題,因為所有搜索結果都描述了來自 javascript 的 AJAX 請求。從技術上講,來自 javascript 的 AJAX 可以解決我的問題,但我更喜歡使用 PHP 純粹在服務器端解決這個問題。以下是迄今為止所發生情況的詳細說明。我已經簡化了很多代碼??蛻粲唵伪砀?php:<form action="CreateOrder.php" method="post" onsubmit="this.submitButton.disabled = true;"> <input name="first"> <input name="second"> <button type="submit">Place Order</button></form>創建訂單.php<?phpbasicOrderProcesses($_POST['first'],$_POST['second']);header("Location: PaymentMethod.php?first=$_POST['first']&second=$_POST['second']");slowOrderProcesses($_POST['first'],$_POST['second']);die();function basicOrderProcesses(){ //Code that is absolutely essential to processing payment}function slowOrderProcesses(){ //Very time consuming code that I'd rather the customer doesn't have to wait for}付款方式.php<h1>Please Select Your Payment Method</h1>...//You get the idea我認為它工作得很好,但隨著slowOrderProcesses()變得更大,代碼運行得更慢。slowOrderProcesses()我現在看到它從未在后臺運行,并且頁面在完成之前不會重定向。如果 CreateOrder.php 在 JavaScript 中運行,我可以輕松編寫一個像這樣的AJAX 解決方案。但它是在純 php 中運行的。等效的 php 解決方案是什么?請記住,當客戶選擇付款方式時,我需要運行緩慢的流程。(如果客戶足夠快的話,甚至可能在客戶付款后繼續運行。)我希望解決方案不需要太多重寫,但我必須做我必須做的事情。(如果可以的話,我會盡量避免安裝庫。)
如何在另一個 php 腳本的后臺運行一個 php 腳本?
慕婉清6462132
2023-07-01 16:53:20