LoginSignup
1
0

More than 1 year has passed since last update.

【PHP基礎③】入力フォームを使おう

Last updated at Posted at 2022-06-13

[問題]  (参照:http://www.cc.kyoto-su.ac.jp/~mmina/bp1/hundredKnocksBasic.html)
整数値を入力させ、その入力値を表示するプログラムを作成しなさい。

コード

$a = intval(fgets(STDIN));
echo $a;

↓ 入力フォームに「70」と入力

結果

70

☆$a = intval(fgets(STDIN)); →変数$aに、入力された整数値を代入する、という意味。
 変数には数値を1つ代入できる。

☆intval() →文字列(string)を整数(int)にする。

☆fgets →第一引数に指定したファイルポインタから1行取得し、その文字列を返す(※もっとわかりやすい説明がほしい…)

☆STDIN(=standard input 標準入力) →ターミナルで入力した文字を標準入力としてPHPに渡す(※こちらももっとわかりやすい説明がほしい…)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0