English 中文(简体)
定有自订功能的支票轮值美元?
原标题:Check wheter $_POST is set with a self-defined function?

为检查轮值而工作的Im是固定的。

下述工作罚款:

if (isset($_POST[ einfo ])) {
    $einfo = $_POST[ einfo ];
} else {  $einfo = NULL; }

重复美元;

And this is the function i m trying to make:

  function  ifset($check) {
       if (isset($_POST[ $check ])) {
     $check = $_POST[ $check ];
    } else {  $check = NULL; }
      return $check;
}

$einfo = ifset( einfo );

重复美元;

但没有产出。

最佳回答

你们必须使用双引:

function ifset($check)
{
  if (isset($_POST["$check"]))
  {
    $check = $_POST["$check"];
  }
  else
  {
    $check = NULL;
  }
  return $check;
}

But actually you can omit them.

问题回答

如果结果是全国人民军,那么当你回声时,它就会被“描绘成空洞”,因此你看不到。

不用<条码>。

你们不要利用双重引言,让加拿大解释这些var。

民族解放军是空洞的,你看不到什么。 如果你想看到一些东西,就试图这样做:

function ifset($check) {
 if (isset($_POST["$check"])) { 
 $check = $_POST["$check"]; 
 } else { 
 $check = "Empty";
 } 
return $check;
}

you need to read a php manual!

$_POST[ $check ] -> string  $check  is as you write
$_POST["$check"] -> string "$check" is a string that contain the $check variable
$_POST[$check] -> equivalent to previous


$check =  some test ;
echo "$check"; // outputs -some test-
echo $check; // outputs -some test-
echo  $check ; // outputs $check

希望这一帮助

That can be done with even less code:

function ifset($check) {
    if (isset($_POST[$check])) {
        return $_POST[$check];
    }
    return NULL;
}

取决于你处理和正在使用PHP5.3+你能使用哪些价值观:

function ifset($check) {
    return $_POST[$check] ?: NULL; // ternary operator
}




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签