Skip to content

Instantly share code, notes, and snippets.

@bdelespierre
Created July 18, 2018 12:48
Show Gist options
  • Save bdelespierre/445166ab6e2ada42905f6ccba4819927 to your computer and use it in GitHub Desktop.
Save bdelespierre/445166ab6e2ada42905f6ccba4819927 to your computer and use it in GitHub Desktop.
<?php
// ----------------------------------------------------------------------------
// $argc: nombre d'argument de la commande
// ----------------------------------------------------------------------------
// e.g. pour la commande 'php file.php foo bar baz',
// $argc vaut 3
// car il y a 3 arguments: "foo", "bar", et "baz"
var_dump($argc);
// ----------------------------------------------------------------------------
// $argv: tableau des arguments de la commande (l'élément zéro est le nom du
// fichier)
// ----------------------------------------------------------------------------
// e.g. pour la commande 'php file.php foo bar baz',
// $argv vaut ['file.php', 'foo', 'bar', 'baz']
// car il y a 3 arguments: "foo", "bar", et "baz"
var_dump($argv);
// ----------------------------------------------------------------------------
// readline('message: '): attend une saisie sur la console et renvoie
// le résultat
// ----------------------------------------------------------------------------
$string = readline('message: ');
var_dump($string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment