LoginSignup
0
1

More than 1 year has passed since last update.

【php】tips

Last updated at Posted at 2022-04-22

入力データの受け取り

$e = trim(fgets(STDIN));

trim = 文字列の先頭や末尾にある空白や改行を取り除く
fgets() = 指定した場所からデータを一行受け取る
STDIN = 標準入力

平方数の判定

与えられた整数の平方根の小数点以下を切り捨て、それを二乗して元の数になるかどうかを判定

function is_square($n)
{
    $sqrt = floor(sqrt($n));
    return ($sqrt*$sqrt == $n);
}

絶対値

abs(-1);
1

ランダム関数

$e = rand(x,y);

x~yの範囲でランダムな値を生成する

0
1
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
0
1