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 trialArikaturika Tumojenko
8,897 Pointsschool.php displays nothing when $firstname and $lastName are empty
I have the following code:
<?php
$firstName = " ";
$lastName = " ";
$currentGrade = 0;
$finalAverage = 0;
$messageBody = " ";
if (!$firstName || !$lastName) {
echo "Please enter a student name";
}
?>
When I run this code in the console, the message "Please enter a student name" doesn't appear. What am I missing, the code looks the same to me as the one Alena is using.
1 Answer
Dave StSomeWhere
19,870 PointsYou have a space in firstName and lastName. The quotes should be touching to be empty. A single space is a valid string value. Instead of $firstName = " ";
try $firstName = "";
Arikaturika Tumojenko
8,897 PointsArikaturika Tumojenko
8,897 PointsThank you :D.