Code: Select all
<?php
echo 'hello world this is sarah';
?>Code: Select all
<?php
$text = 'hello world this is sarah';
echo $text;
?>Code: Select all
<?php
$text = 'hello world this is sarah';
$num = 10;
$joiner = ' and I am ';
if ($num == 10)
{
echo $text . $joiner . $num;
}
elseif ($num == 11)
{
echo 'I am 11';
}
else
{
echo 'I am totally not 10';
}
echo '<br />';
$counter = 0;
$limit = 100;
$inc = 10;
while ($counter < $limit)
{
if (!($counter % 10))
{
echo '<h2>10 is a modulator of ' . $counter . '!</h2>';
}
else
{
echo '<p>I am only ' . $counter . '</p>';
}
$counter += $inc;
}
$now = time();
echo date('l F jS, Y', $now);
?>Me: How does PHP know when it is the end of the line?
They: The semicolon.
Me: What do the quotation marks on a variable value mean?
They: That the value is a string.
Me: If we loop do a while loop where a var is less than 100, what is the maximum value we'll see when echoing the increment value?
They: 99.
Me: And if we change the increment value to 10, what is the largest value we'll see?
They: 90.
Unbelievable. Even a 9 and 10 year old can get this pretty quickly.
/ apologizes for the blog like post, but I just wanted to encourage those folks that think this is too hard to pick up on. Start slow and it can be learned. Just ask my kids.
EDIT | I should note that they are by no means pros at this. But they have a strong understanding of the concepts, as evidenced by their ability to tell me what would appear on the screen as they read the code line by line.