What are the best practices for retrieving the process ID of an application running in PHP under Windows?

When running a PHP application on Windows, you may need to retrieve the process ID (PID) of the application for various reasons, such as monitoring or controlling the process. One way to achieve this is by using the `exec` function in PHP to execute a command that retrieves the PID of the running application.

// Retrieve the process ID of the PHP application running on Windows
$pid = exec('wmic process where (Name="php.exe") get ProcessId /value');
echo "Process ID: " . $pid;