Home  >  Q&A  >  body text

How to determine whether the passed parameter is a variable?

function is_var($var){//???How to write}$a = 123;var_dump(is_var($a));//true

var_dump(is_var('456')) ;//falsevar_dump(is_var(456));//falsevar_dump(is_var([1,2,3]));//false...

That is, pass the parameters directly If a value is written, false is returned. If a variable is defined, true is returned.

Is there any way? . .

扬帆起航扬帆起航576 days ago919

reply all(3)I'll reply

  • 飞天001

    飞天0012022-11-18 22:48:01

    Can I judge that the one with $ in front is a variable? I am a novice and I am just talking nonsense.

    reply
    0
  • 扬帆起航

    扬帆起航2022-11-15 10:34:16

    How can I edit a post without deleting it? . . . The first time I posted, it showed up in a mess. . .

    reply
    0
  • 扬帆起航

    扬帆起航2022-11-15 10:32:16

    function is_var($var){

    //???How to write

    }

    $a =123;

    var_dump(is_var ($a));//true

    var_dump(is_var('456'));//false

    var_dump(is_var(456));// false

    var_dump(is_var([1,2,3]));//false

    ......

    That is, if you pass the parameter and write the value directly, return false , if a variable is defined, return true

    Is there any way? . .

    reply
    0
  • Cancelreply