Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What is going on with this article?

More than 3 years have passed since last update.

@ShibuyaKosuke

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

filter_input

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

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


<?php

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

このように使います。

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

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

2
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
2
Help us understand the problem. What is going on with this article?