Using a variable in an if/for/do-while block in php -


If I'm not mistaken, then I used a new statement or new PHP variable for the first time in a conditional loop block. What I want to say is like the following.

  & lt; For php ($ i = 0; $ i & lt; 10, $ i ++) {$ total + = $ i; $ Concat = $ I; }? & Gt;   

But today, when I look at the error log, it says that $ total and $ concet are undefined variables then I write this

  $ Total = 0; $ Concat = ""; ($ I = 0; $ i & lt; 10; $ i ++) for {$ total + = $ i; $ Concat = $ I; }? & Gt;   

Why does it work with an error? Only ask for curiosity

The reason for this is:

  $ Total + = $ i; $ Concat = $ I;   

In fact it means: $ total = $ total + $ i; $ Concat = $ concat $ I;

The first time you execute the loop, you get an error if $ total and $ concat are undefined.

More details:

During the first part of the loop, you

  total $ = undefined $ total + $ The value of i;   

Now, the total has been defined for $ concat also.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -