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, 17 May 2013

view this page in

$argc

(PHP 4, PHP 5)

$argcLe nombre d'arguments passés au script

Description

Contient le nombre d'arguments passés au script courant lorsqu'il est exécuté depuis la ligne de commande.

Note: Le nom du fichier contenant le script est toujours passé en tant qu'argument au script, toutefois, la valeur minimale de $argc est 1.

Note: Cette variable n'est pas disponible lorsque register_argc_argv est désactivé.

Exemples

Exemple #1 Exemple avec $argc

<?php
var_dump
($argc);
?>

Lorsque l'on exécute l'exemple avec la commande : php script.php arg1 arg2 arg3

L'exemple ci-dessus va afficher quelque chose de similaire à :

int(4)



$argv> <$http_response_header
[edit] Last updated: Fri, 17 May 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
2 years 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