popen

(PHP 3, PHP 4 )

popen -- Apre un puntatore ad un file di processo

Descrizione

int popen ( string command, string mode)

Apre una pipe ad un processo eseguito forzando il comando dato da command.

Restituisce un puntatore a file identico a quello restituito da fopen(), eccetto che per il fatto che č unidirezionale (puņ solo essere usato per la lettura o la scrittura) e deve essere chiudo con pclose(). Questo puntatore puņ essere usato con fgets(), fgetss() e fputs().

Se si verifica un errore, restituisce FALSE.

$fp = popen ("/bin/ls", "r");

Nota: If the command to be executed could not be found, a valid resource is returned. This may seem odd, but makes sense; it allows you to access any error message returned by the shell:

<?php
error_reporting(E_ALL);

/* Add redirection so we can get stderr. */
$fp = popen('/path/to/spooge 2>&1', 'r');
echo "'$fp'; " . gettype($fp) . "\n";
$read = fread($fp, 2096);
echo $read;
pclose($fp);
?>

Vedere anche pclose().