创建一个简单的文本文件,其中包含有以下PHP代码,并把它保存为hello.php:
复制代码 代码如下:
echo "Hello from the CLI";
?>
复制代码 代码如下:
// ask for input
fwrite(STDOUT, "Enter your name: ");
// get input
$name = trim(fgets(STDIN));
// write input back
fwrite(STDOUT, "Hello, $name!");
?>
复制代码 代码如下:
print_r($argv);
?>
复制代码 代码如下:
// check for all required arguments
// first argument is always name of script!
if ($argc != 4) {
die("Usage: book.php
}
// remove first argument
array_shift($argv);
// get and use remaining arguments
$checkin = $argv[0];
$nights = $argv[1];
$type = $argv[2];
echo "You have requested a $type room for $nights nights, checking in on $checkin. Thank you for your order! ";
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号