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

search for in the

$argv> <$http_response_header
Last updated: Fri, 20 May 2011

view this page in

$argc

$argcEl número de argumentos pasados a un script

Descripción

Contiene el número de argumentos pasados al script actual cuando se ejecuta desde la línea de comandos.

Note: El nombre del script es pasado siempre como argumento del script, por lo tanto, el valor mínimo de $argc es 1.

Note: Esta variable sólo está disponible cuando register_argc_argv está activado.

Ejemplos

Example #1 Ejemplo de $argc

<?php
var_dump
($argc);
?>

Cuando se ejecuta el ejemplo con: php script.php arg1 arg2 arg3

El resultado del ejemplo sería algo similar a:

int(4)



$argv> <$http_response_header
Last updated: Fri, 20 May 2011
 
add a note add a note User Contributed Notes $argc
Tejesember 04-May-2011 04:50
To find out are you in CLI or not, this is much better in my opinion:
<?php
if (PHP_SAPI != "cli") {
    exit;
}
?>
anonymous 21-Oct-2010 09:26
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;
}
?>
karsten at typo3 dot org 18-Feb-2009 08:47
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

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