Variable initialization how do you write

Source: Internet
Author: User
Initialization of variables How do you write?
Low number of variable initialization
If it's a lot of time, it's a little uncomfortable.

$a, $b, $c, $d, $e .....

Written like this
$a = 0;
$b = 0;
$c = 0;
$d = 0;
$e = 0;
....

Not good, inconvenient, uncomfortable ...

So how do you initialize it? Don't tell me not to initialize, turn off the error prompt.


------Solution--------------------
$a = $b = $c =...=0;
$d = $e =...=array ();
Is this a good thing to watch? Haha, I didn't get too many variables to initialize.
------Solution--------------------
If there is no law, then we can only human flesh. There are rules to write. If the extract/list can be used from the array;
Quote a paragraph:
PHP Code
$my _array = Array ("A" = "Cat", "b" = "Dog", "c" = "Horse"), extract ($my _array); echo "\ $a = $a; \ $b = $b; \ $c = $c ";  Output: $a = Cat; $b = Dog; $c = Horse
------Solution--------------------
I won't design so many variables haha. Just write a few lines.
------Solution--------------------
PHP allows non-initialization of variables, which shows the flexibility and simplicity of PHP
If you must initialize it,
Extract (Array_flip (Explode (', ', ' a,b,c,d,e,f,g,h '));

$a = 0;
$b = 0;
$c = 0;
$d = 0;
$e = 0;
.... Bother!!

$a = $b = $c =...=0;
$d = $e =...=array (); also annoying!!

------Solution--------------------
One day, when PHP becomes a compiled language, it's not annoying. What's bothering you?
------Solution--------------------
Not only to write interlaced, but also to fill each line with comments.
What does the report say about initializing so many variables? Share your design.
I've also done a custom report function, select the selection of the selected fields to add statistics to add a filter search, it seems like there is no need to initialize multiple variables.
------Solution--------------------
Originally people PHP design time, is can be variable when use when define, do not know. The elder brother, modified PHP into a similar strong type of nondescript things. Like a bastard. It's not easy, PHP programmers are hard-pressed.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.