Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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;