Is there a C # s Process.Start equivalent in PHP?

  • In .NET, the Process class contains several useful properties / methods that allow developers to access relative process information. Is there an equivalent method or class in PHP?

  • Is there any equivalent method in PHP like the C # method "Process.Start ()"?

+5
source share
6 answers

1.See Program Execution Functions

In addition, there is no concept of methods / classes / properties / namespaces in standard PHP functions. PHP is essentially a procedural programming language with several OOP constructs and namespace support, which are added as a new function from the latest major version (5.3). This is one of the reasons why people criticize it as a "toy" language. You can access all the built-in PHP functions all the time, not annoying namespaces to interfere;), just be careful with name collisions.

2. @YSJaitawat The correct answer is poor help.

Click this link for documentation of the exec function in the PHP manual .

. , # PHP , PHP , - , . , , - , .

+4

, "Process.Start()"

$executable = ' '; Exec ($ );

http://php.net/manual/en/book.pcntl.php

+4

Evan Plaice , POSIX - , - , Unix/Linux, . , manual

, . Net, Microsoft , . GTK MSWindows, .

+1

COM-, ( , ), Windows ( , Linux, ),

$com = new COM('WScript.Shell');
$com->run('Path/To/Shell/Program', 0, false);

.

0

.NET Process /, . PHP.

, / , , / . #, , , , , PHP :

PHP script NORMAL, . ABORTED . STOP. PHP (. set_time_limit()), TIMEOUT .

... connection_status():

switch (connection_status())
{
    case CONNECTION_NORMAL:
        // ...
    break;

    case CONNECTION_ABORTED:
        // ...
    break;

    case CONNECTION_TIMEOUT:
        // ...
    break;
}

POSIX ( POSIX) . , , sys_getloadavg() , , .

- PHP, # "Process.Start()".

, :

Windows COM, :

$cmd = new COM('WScript.Shell');

In addition, if you want to be safe from attacks using code, do not forget that any user input must be escaped with escapeshellarg()or escapeshellcmd().

0
source

All Articles