system() es similar a la versión C de la función de mismo nombre, dado que ejecuta el comando dado y muestra el resultado. Si se entrega una variable como segundo argumento, entonces el código de status devuelto por el comando ejecutado será escrito en esta variable.
Aviso |
If you are going to allow data coming from user input to be passed to this function, then you should be using escapeshellarg() or escapeshellcmd() to make sure that users cannot trick the system into executing arbitrary commands. |
Nota: If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.
La llamada a system() también intenta volcar automáticamente el búfer de salida del servidor web después de cada línea de salida, si PHP está corriendo como un módulo de servidor.
Devuelve la última línea de la salida del comando en caso de éxito, y FALSE si se presenta algún fallo.
Si necesita ejecutar un comando y recibir de vuelta todo los datos del mismo sin interferencias, use la función passthru().
Nota: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable.
Aviso |
With safe mode enabled, all words following the initial command string are treated as a single argument. Thus, echo y | echo x becomes echo "y | echo x". |
Vea también exec(), passthru(), popen(), escapeshellcmd(), pcntl_exec() y el operador de comilla invertida.