3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

カンマ区切りの数値入力を制限する必要がないぞ!

Posted at

filter_input

これの第二引数の部分なのですが。

フィルタフラグFILTER_SANITIZE_NUMBER_FLOAT なるものを発見。


<?php

$price = filter_input(INPUT_POST, 'price', FILTER_SANITIZE_NUMBER_FLOAT);

このように使います。

すると、ユーザーがテキストボックスに 10,000 のように入力しても、ちゃんと、10000が $price に代入されるんですね〜。

ユーザーの入力に対して、「カンマを入れちゃダメよー」ってする必要がないという話でした。

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?