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 trial

PHP Build a Simple PHP Application Wrapping Up The Project Objects

adrien kovanic
adrien kovanic
5,727 Points

Hi I can't figure out the use of the empty braquets : echo "The number " . $checker->number . " "; thanks a lot

the question says it all :)

palprimes.php
<?php



 require_once("class.palprimechecker.php");
$checker = new PalprimeChecker();
$checker->number = 17;
echo "The number " . $checker->number . " ";
echo "(is|is not)";
echo " a palprime.";

?>

2 Answers

Benjamin Payne
Benjamin Payne
8,142 Points

Hey Adrien,

This could also be written like this.

<?php

require_once("class.palprimechecker.php");
$checker = new PalprimeChecker();
$checker->number = 17;
echo "The number 17 {$checker->number } a palprime"

?>

You can uaw concatenation like you are doing, using periods to bring strings together.

I cannot remember what the palprime checker returns but my example assumes it returns 'is or is not'. If it returns true / false you can use this example.

<?php

require_once("class.palprimechecker.php");
$checker = new PalprimeChecker();
$palprime = $checker->number = 17
$palprime = ($palprime === true) ? 'is' : 'is not';

echo "The number 17 $palprime a palprime"

?>

Let me know if that helps.

Best,
Ben

echo "The number " . $checker->number;