Whoops!
It looks like there might be an issue playing videos in this browser. We're working on better cross-brower experience, but in the meantime please try the latest Chrome or Firefox browsers. Or, you may be able to watch the video directly without progress tracking or transcript:
.webm video
.mp4 video
The line of code which brought on confusion is as follows:
// 3. A practical function to roll dice.
function roll_dice($highest_number = 6, $num_dice = 1) {
$output = '';
for($i = 0; $i < $num_dice; $i++) {
$number = rand(1, $highest_number);
$output .= ' [' . $number . '] ';
}
$output = 'The result of your roll was: ' . $output;
return $output;
}
the $output variable including the $output variable within it is what confused me however its a rather simple function of appendage. Below is from an explanation I received from irc that will provide a better explanation than I can.
Jobe how about an example
14:12 Jobe $a = "Hello ";
14:12 Jobe $a now contains "Hello "
14:12 Jobe $a = $a . "world";
14:12 Jobe $a now contains "Hello world"
14:13 Jobe this:
14:13 Jobe $a = $a . "world";
14:13 Jobe can also be written as:
14:13 Jobe $a .= "world";
14:13 RobMcGill so its appending the additional data onto the existing variable?
14:13 Jobe yes
14:14 Jobe there are numerous "=" assignment operators
14:14 Hercule to a string infact
14:14 Jobe including but not limited to "/=", "+=", "-=", "*=" etc...
14:14 Jobe they can all be expanded in the same way "$a .= "world";" can be to "$a = $a . "world";"
14:15 Jobe for example
14:15 Jobe say you do:
14:15 Jobe $a = 5;
14:15 Jobe then did:
14:15 Jobe $a += 5;
14:15 Jobe $a would then contain 10