How do you write variable initialization? A small number of variables initialize. if the number is large, it will be a little uncomfortable. $ a, $ B, $ c, $ d, $ e ..... write $ a = 0; $ B = 0; $ c = 0; $ d = 0; $ e = 0 ;.... not easy to read, inconvenient, uncomfortable... so how do you initialize it? Don't tell me not to initialize. close the error prompt ., $ a = $ B = $ c =... = 0; $ d = $ e =... = How do you write arra variable initialization?
A small number of variables
If the number is large, it will be a little uncomfortable.
$ A, $ B, $ c, $ d, $ e .....
Write it like this
$ A = 0;
$ B = 0;
$ C = 0;
$ D = 0;
$ E = 0;
....
Not easy to read, inconvenient, uncomfortable...
So how do you initialize it? Don't tell me not to initialize. close the error prompt.
------ Solution --------------------
$ A = $ B = $ c =... = 0;
$ D = $ e =... = array ();
So nice to see? Haha, I haven't met many variables that need initialization.
------ Solution --------------------
If there are no rules, then we can only be human. Write normally. If you can use extract/list from the array;
Reference section:
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 honestly.
------ Solution --------------------
Php does not allow initialization of variables, which shows the flexibility and simplicity of php.
If initialization is required
Extract (array_flip (explode (',', 'a, B, c, d, e, f, g, h ')));
$ A = 0;
$ B = 0;
$ C = 0;
$ D = 0;
$ E = 0;
... Annoying !!
$ A = $ B = $ c =... = 0;
$ D = $ e =... = array (); also annoying !!
------ Solution --------------------
When php becomes a compiled language, you will not bother. What do you get bored ....
------ Solution --------------------
Not only do I have to write data in different rows, but also add comments to each line.
Why do we need to initialize so many variables in a report? Share your design.
I have also done a custom report function. I select a table, select a field, select an association, select a condition, add statistics, and add a filter search. it seems that there is no need to initialize multiple variables.
------ Solution --------------------
When php was designed, it was impossible to define variables when they were used. That guy corrected php to something similar to a strong type. Just like a hybrid. It's not easy. it's hard for php programmers.