
【PHP/演習問題】コマンドライン引数[2]
問題
次の実行結果になるプログラムを作成してください。
なお、下記の条件を満たすものとします。
- 実行結果の文字列はコマンドライン引数の値を使用
$ php practice.php Have a good night!
Have a good night!
解答例
<?php
$text1 = $argv[1];
$text2 = $argv[2];
$text3 = $argv[3];
$text4 = $argv[4];
echo $text1.' '.$text2.' '.$text3.' '.$text4."\n";
?>