LoginSignup
7
9

More than 5 years have passed since last update.

スーパーグローバル変数にfilter_input関数を使うときの注意点

Posted at

ソースから$_POST/$_GETに値を代入した場合、filter_input関数を使っていると値を取得できないため、filter_var関数を使用する。

php
<?php

//ここで代入
$_POST['hoge']='piyo';

$fInput=filter_input(INPUT_POST,'hoge');
var_dump($fInput);
// NULL

$fVar=filter_var($_POST['hoge']);
var_dump($fVar);
// string(4) "piyo"
7
9
2

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
7
9