downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

$argv> <$http_response_header
[edit] Last updated: Fri, 26 Apr 2013

view this page in

$argc

$argcO número de argumentos passados para o script

Descrição

Contém o número de argumentos passados para o atual script quando executando através da linha de comando.

Nota: O nome do arquivo do script é sempre passado como um argumento para o script, portanto o valor mínimo de $argc é 1.

Nota: Esta variável está sempre disponível quando register_argc_argv está habilitada.

Exemplos

Exemplo #1 Exemplo da $argc

<?php
var_dump
($argc);
?>

Quando executando o exemplo com: php script.php arg1 arg2 arg3

O exemplo acima irá imprimir algo similar à:

int(4)



$argv> <$http_response_header
[edit] Last updated: Fri, 26 Apr 2013
 
add a note add a note User Contributed Notes $argc - [3 notes]
up
1
karsten at typo3 dot org
4 years ago
Note: when using CLI $argc (as well as $argv) are always available, regardless of register_argc_argv, as explained at http://docs.php.net/manual/en/features.commandline.php
up
1
Tejesember
1 year ago
To find out are you in CLI or not, this is much better in my opinion:
<?php
if (PHP_SAPI != "cli") {
    exit;
}
?>
up
-1
anonymous
2 years ago
I use the following lines to check if i'm using CLI mode or not :

<?php
$cli_mode
= false;
if ( isset(
$_SERVER['argc']) && $_SERVER['argc']>=1 ) {
 
$cli_mode = true;
}
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites