⇧
vadnica-logo
Editor My Blog Password Manager Finance My Services About the Project Telegram O meni O meni

Advanced Tools

In this chapter, we will look at functions that allow deep control over script execution and communication with the client (browser). These functions are crucial when we want to safely terminate a script or when we need to process raw binary data.

EXAMPLE
RESULT
The result will be displayed here...

Overview of Advanced Functions

Function Description Example
die() / exit() Outputs a message and terminates the execution of the current script. die("End");
connection_status() Returns the bitwise status of the current connection with the browser. 0 = Normal
connection_aborted() Checks whether the user closed the window or aborted the loading. Returns true/false
ignore_user_abort() Sets whether a script should continue executing even if the user closes the window. Useful for long processes
pack() / unpack() Pack and unpack binary data string. For working with bytes

1. Forced Termination (die & exit)

These two functions are practically identical. We use them when continuing the code makes no sense – for example, if we cannot connect to the database or if the user does not have permissions to view the page. Everything below die() is completely ignored by the server.

2. Abort Control

Did you know that a PHP script usually stops working the moment the user clicks the "X" in the browser or closes the tab? With the ignore_user_abort(true) function, we can command the server to execute the script to the end (e.g., to safely write data to the database), regardless of what the user does.