Proper way to declare multiple vars in PHP

后端 未结 7 1839
清歌不尽
清歌不尽 2021-01-31 01:48

I\'ve been coding personal scripts for years in PHP and get used to turn off Error display. I\'m about to release some of these scripts and would like to do it the proper way.

7条回答
  •  猫巷女王i
    2021-01-31 02:12

    In OOP you can use this approach:

    protected $password, $full_name, $email;
    

    For non-OOP you declare them just in code they will be Undefined if you didn't assign any value to them:

    $foo; $bar; $baz;
    
    $set_foo =  (isset($foo)) ? $foo : $foo = 'Foo';
    echo $set_foo;
    

提交回复
热议问题