Proper way to declare multiple vars in PHP

后端 未结 7 1893
清歌不尽
清歌不尽 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条回答
  •  离开以前
    2021-01-31 02:06

    I posted this in a comment earlier, but someone suggested I submit it as an answer.

    The shortest and simplest way I can think of, is to do:

    $foo = $bar = $ping = $pong = '';
    

    I often prefer to set things to false, instead of an empty string, so that you can always do checks in the future with === false, but that is just a preference and depends on how you are using these variables and for what.

提交回复
热议问题