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

search for in the

Excepciones predefinidas> <$argc
Last updated: Fri, 20 May 2011

view this page in

$argv

$argvArray de argumentos pasados a un script

Descripción

Contiene un array de todos los argumentos pasados a un script cuando se ejecuta desde la línea de comandos.

Note: El primer argumento siempre es el nombre del fichero del script actual, por lo tanto $argv[0] es el nombre del fichero.

Note: Esta variable solamente está disponible cuando esta activado register_argc_argv.

Ejemplos

Example #1 Ejemplo de $argv

<?php
var_dump
($argv);
?>

Cuando se ejecuta el ejemplo con: php script.php arg1 arg2 arg3

El resultado del ejemplo sería algo similar a:

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

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