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)

$argcDie Anzahl der an das Skript übergebenen Argumente

Beschreibung

Enthält die Anzahl der an das aktuelle Skript übergebenen Argumente, wenn das Skript auf der Kommandozeile läuft.

Hinweis: Der Dateiname des Skripts ist immer das erste an das Skript übergebene Argument, damit ist der kleinstmögliche Wert von $argc 1.

Hinweis: Diese Variable ist nicht verfügbar, wenn register_argc_argv ausgeschaltet ist.

Beispiele

Beispiel #1 $argc-Beispiel

<?php
var_dump
($argc);
?>

Wenn das Beispiel so aufgerufen wird: php script.php arg1 arg2 arg3

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

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
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
0
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;
}
?>
up
0
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

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