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, 30 Nov 2012

view this page in

$argc

(PHP 4, PHP 5)

$argcThe number of arguments passed to script

Opis

Contains the number of arguments passed to the current script when running from the command line.

Informacja: The script's filename is always passed as an argument to the script, therefore the minimum value of $argc is 1.

Informacja: This variable is not available when register_argc_argv is disabled.

Przykłady

Przykład #1 $argc example

<?php
var_dump
($argc);
?>

When executing the example with: php script.php arg1 arg2 arg3

Powyższy przykład wyświetli coś podobnego do:

int(4)



$argv> <$http_response_header
[edit] Last updated: Fri, 30 Nov 2012
 
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