This should be easy for you all. This is just a small chunk of code and should take no time to figure out for PHP experts. I'm also just starting out in PHP.
$counter = 1;
while ( $counter <= 12 )
{ print "$counter times 2 is ".($counter*2)."<br>";
$counter++
}
Basically, I don't know what the ".($counter*2)."<br>" thing does.
From what I understand..
First Line :
$counter is declared and set the value of "1"
Second Line :
Whenever the while statement expression is true. That is, whenver $counter contains a number that is smaller than or equal to 12, the below code block enclosed in {} will run on and on.
Third line :
I don't understand that. its like all gibberish to me. From what I currently know, it prints ( or outputs ) the value inside the " " parentheses. And counter*2 is definitely the variable $counter x 2 ( multplied by 2 )
Fourth Line:
Increment ( add 1 ) to counter
Last line :
End code block
IN THER WORDS:
PHP is asked to print "$counter times 2 is ".($counter*2)."<br>"
I understand that $counter would evaluate to 1
Thus, PHP is to print
1 times 2 is ".($counter)*2."<br>
What does the brackets enclosing $counter above do? I'm not sure of what the dot do, but its supposed to connect the left and right strings together. Therefore,
1 times 2 is "($counter)^2}"<br>
What is that that pair of " signs do? and what does the bracket tell php to do? Is it possible that the " " signs tell php that the stuff inside are to be evaluated ( is an expression )?
I'm so confused. Thnx in advnce.
$counter = 1;
while ( $counter <= 12 )
{ print "$counter times 2 is ".($counter*2)."<br>";
$counter++
}
Basically, I don't know what the ".($counter*2)."<br>" thing does.
From what I understand..
First Line :
$counter is declared and set the value of "1"
Second Line :
Whenever the while statement expression is true. That is, whenver $counter contains a number that is smaller than or equal to 12, the below code block enclosed in {} will run on and on.
Third line :
I don't understand that. its like all gibberish to me. From what I currently know, it prints ( or outputs ) the value inside the " " parentheses. And counter*2 is definitely the variable $counter x 2 ( multplied by 2 )
Fourth Line:
Increment ( add 1 ) to counter
Last line :
End code block
IN THER WORDS:
PHP is asked to print "$counter times 2 is ".($counter*2)."<br>"
I understand that $counter would evaluate to 1
Thus, PHP is to print
1 times 2 is ".($counter)*2."<br>
What does the brackets enclosing $counter above do? I'm not sure of what the dot do, but its supposed to connect the left and right strings together. Therefore,
1 times 2 is "($counter)^2}"<br>
What is that that pair of " signs do? and what does the bracket tell php to do? Is it possible that the " " signs tell php that the stuff inside are to be evaluated ( is an expression )?
I'm so confused. Thnx in advnce.













