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

search for in the

Exceptions prédéfinies> <$argc
Last updated: Fri, 14 Aug 2009

view this page in

$argv

$argvTableau d'arguments passé au script

Description

Contient un tableau de tous les arguments passés au script lorsqu'il est passé depuis la ligne de commande.

Note: Le premier argument est toujours le nom du fichier contenant le script, toutefois, $argv[0] correspond au nom du script.

Note: Cette variable n'est disponible que lorsque register_argc_argv est activé.

Exemples

Exemple #1 Exemple avec $argv

<?php
var_dump
($argv);
?>

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 à :

array(4) {
  [0]=>
  string(10) "script.php"
  [1]=>
  string(4) "arg1"
  [2]=>
  string(4) "arg2"
  [3]=>
  string(4) "arg3"
}



add a note add a note User Contributed Notes
$argv
Steve Schmitt
14-Sep-2009 11:57
If you come from a shell scripting background, you might expect to find this topic under the heading "positional parameters".
karsten at typo3 dot org
18-Feb-2009 08:48
Note: when using CLI $argv (as well as $argc) is always available, regardless of register_argc_argv, as explained at http://docs.php.net/manual/en/features.commandline.php

Exceptions prédéfinies> <$argc
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites