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
[edit] Last updated: Fri, 25 May 2012

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, 25 May 2012
 
add a note add a note User Contributed Notes $argc
Tejesember 04-May-2011 09: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 02: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 12: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