Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialdemian arizaleta
3,382 PointsWhy do i only get 1919 instead all the hundred years before?
<?php
$currentYear = date('Y');
$year = $currentYear - 100;
while (++$year <= $currentYear) {
echo $year . "<br /<\n";
$year++;
}
?>
4 Answers
Antonio De Rose
20,885 Pointsnope. yours to mine, is the same in terms of your first edition, generally, if you read my notes, you'd be able to do it, my notes are commented issue is in this line
<?php
echo $year . "<br /<\n";
//it has to be like the below
echo $year . "<br />";
Antonio De Rose
20,885 Pointsbecause, you have got an error
<?php
$currentYear = date('Y');
$year = $currentYear - 100;
while (++$year <= $currentYear) {
echo $year . "<br /<\n"; // here is the error , try this, echo $year . "<br />";
$year++;
}
//by the way, you will not be able to see, 100 years, instead 50 years only, as you are incrementing by 2
//which in return will skip every alternative year.
?>
demian arizaleta
3,382 PointsDont really see the diference and i copy and paste it and still only get 1919:/
Antonio De Rose
20,885 Pointssend the new code
demian arizaleta
3,382 PointsLiterally just copied yours, does it work well for you ?
Antonio De Rose
20,885 Pointsyeap, you could use both together
not like the way you have used, cause, I think there is a type, closing bracket for br is mistaken with another opening bracket.
<?php
//your way
echo $year . "<br /<\n";
//the correct way
echo $year . "<br />\n";
demian arizaleta
3,382 PointsOk i see it now thanks alot
demian arizaleta
3,382 Pointsdemian arizaleta
3,382 PointsOk silly me, didnt see the echo at the end of the line haha. Now it works but im a bit confused because in the video Alena writes both line break they even discuss this on another question here :https://teamtreehouse.com/community/why-do-i-need-both-br-and-n