Hướng dẫn force stop php script - buộc dừng tập lệnh php

Tôi đã viết mã PHP như thế này:


Tôi đã lưu nó trong thư mục webserver. Tôi bắt đầu nó thông qua trình duyệt của tôi. Làm thế nào tôi có thể dừng tập lệnh trong khi thực hiện?during execution?

Trân trọng ;)

Hướng dẫn force stop php script - buộc dừng tập lệnh php

Potashin

43.6K11 Huy hiệu vàng81 Huy hiệu bạc105 Huy hiệu Đồng11 gold badges81 silver badges105 bronze badges

Hỏi ngày 8 tháng 1 năm 2015 lúc 6:55Jan 8, 2015 at 6:55

3

Nếu bạn đang ở trên hệ thống Unix, hãy làm điều này:

ps aux | grep php Nó sẽ liệt kê tất cả các quy trình đang chạy là trường hợp của PHP. Nếu tập lệnh của bạn được gọi là myscript.php, thì bạn sẽ thấy php /path/oto/myscript.php trong danh sách này khi nó chạy.
it will list all running processes which are instances of php. If you're script is called myscript.php, then you should see php /path/to/myscript.php in this list when it's running.

Bây giờ bạn có thể giết nó bằng lệnh kill -9 PID

Nếu bạn đang chạy trên Windows, bạn không thể (trừ khi bạn có thể kéo lên trình quản lý tác vụ theo cách thủ công) và nếu bạn chỉ có truy cập trình duyệt web vào máy chủ và bạn đang chạy tập lệnh qua máy chủ web một lần nữa, bạn không thể giết quá trình. Dù bằng cách nào chạy một tập lệnh vòng lặp vô hạn mà không có khả năng giết nó trên lệnh là một ý tưởng tồi.

Tham khảo cách phát hiện dừng hoặc chạy tập lệnh PHP từ ngoài và nền

Đã trả lời ngày 8 tháng 1 năm 2015 lúc 7:08Jan 8, 2015 at 7:08

1

Thoát (0); hay là chết(); hoặc phá vỡ; Bạn có thể sử dụng bất kỳ một. you can use any one.

?>

    output: 0   //script is stop after printing 0.

Đã trả lời ngày 8 tháng 1 năm 2015 lúc 7:06Jan 8, 2015 at 7:06

PriyankpriyankPriyank

3.6403 huy hiệu vàng28 Huy hiệu bạc47 Huy hiệu đồng3 gold badges28 silver badges47 bronze badges

Bạn hoặc sử dụng exit() hoặc die() cho các mục đích này. Nhưng ví dụ của bạn, điều này không thực sự cần thiết vì kịch bản sẽ tự hủy bỏ sau khi nó chạy.

Đã trả lời ngày 8 tháng 1 năm 2015 lúc 6:59Jan 8, 2015 at 6:59

Hướng dẫn force stop php script - buộc dừng tập lệnh php

RealitätsverlustrealitätsverlustRealitätsverlust

3.9132 Huy hiệu vàng21 Huy hiệu bạc46 Huy hiệu đồng2 gold badges21 silver badges46 bronze badges

1

sunfundev tại gmail dot com

5 năm trướcOutput a message and terminate the current script

Alexyam tại Live Dot Com ¶

10 năm trước(string $status = ?): void

Devinemke tại Devinemke dot com(int $status): void

20 năm trước

Powtac tại GMX de ¶

4 năm trước

Shaun tại Noshatspam Dot Net

Chris at Ocproducts Dot Com ¶int, that value will be used as the exit status and not printed. Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.

Matt tại serverboy dot net ¶

Kehaovista tại qq dot com ¶

6 năm trước

Alexander Behling ¶

7

8

9

1 năm trước

    output: 0   //script is stop after printing 0.
1

(Php 4, Php 5, Php 7, Php 8)

    output: 0   //script is stop after printing 0.
2

    output: 0   //script is stop after printing 0.
3

    output: 0   //script is stop after printing 0.
4

Thoát - xuất một tin nhắn và chấm dứt tập lệnh hiện tại

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 

Sự mô tả

11 năm trước

    output: 0   //script is stop after printing 0.
5

    output: 0   //script is stop after printing 0.
6

    output: 0   //script is stop after printing 0.
7

    output: 0   //script is stop after printing 0.
8

    output: 0   //script is stop after printing 0.
9

Albert tại Removeethis Dot Peschar Dot Net

13 năm trước

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
0

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
1

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
2

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

theonenkl tại gmail dot com ¶

7 năm trước

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
4

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
5

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
6

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
7

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
8

Vincent dot laag tại gmail dot com ¶

12 năm trước

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
9

vô hiệu hóa một thông tin t t thông tin ¶

13 năm trước

ps aux | grep php0

ps aux | grep php1

ps aux | grep php2

ps aux | grep php3

ps aux | grep php4

ps aux | grep php5

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

Emils tại TVNet Dot LV ¶

19 năm trước

ps aux | grep php7

m dot ressergolis tại gmail dot com ¶

7 năm trước

ps aux | grep php8

ps aux | grep php9

kill -9 PID0

kill -9 PID1

kill -9 PID2

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

Vincent dot laag tại gmail dot com ¶

12 năm trước

kill -9 PID4

kill -9 PID5

kill -9 PID6

kill -9 PID7

kill -9 PID8

vô hiệu hóa một thông tin t t thông tin ¶

Emils tại TVNet Dot LV ¶

kill -9 PID9

exit()0

exit()1

exit()2

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

19 năm trước

m dot ressergolis tại gmail dot com ¶

exit()4

exit()5

exit()6

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

sunfundev tại gmail dot com

5 năm trước

exit()8

Alexyam tại Live Dot Com ¶

m dot ressergolis tại gmail dot com ¶

exit()9

die()0

die()1

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

sunfundev tại gmail dot com

5 năm trước

die()3

die()4

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

Alexyam tại Live Dot Com ¶

12 năm trước

die()6

die()7

die()8

die()9

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3

vô hiệu hóa một thông tin t t thông tin ¶

Emils tại TVNet Dot LV ¶

$status1

$status2

$status3

19 năm trước

m dot ressergolis tại gmail dot com ¶

$status4

$status5

$status6

$status7

$status8

$status9

 Shutdown: shutdown()
 Destruct: Foo::__destruct()
 
3