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


oophp not working on xamp weird?

I want to experiment myself very first time following the video on OOPHP basic that was stage 2 related to method and properties. I was copying from their code into my file and i would like to check it out with my XAMP.

I turned on XAMP engine. I went to http://localhost/oop.php and got out of the blue.
It was error it said " Notice: Use of undefined constant ‘default_name’ - assumed '‘default_name’' in C:\xampp\htdocs\oop.php on line 13 Product Name: ‘default_name’"

I have noticed their URL were hampton.dev/ not using the localhost. hmm?

I do not know what does it mean?

The code is

class Product
    // properties
    public $name = ‘default_name’;

    public function getInfo (){
        return "Product Name: ". $this->name;

$p = new Product();
echo $p->getInfo(); 

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Brian,

The problem is the fancy quotes in your code, currently you have the following.

public $name = ‘default_name’;

Instead it should be the following and it should work, as a reminder PHP requires correctly formatted single and double quotes as the parsing engine can't compile fancy quotes.

public $name = 'default_name';

wow you have an eagle eye! you are lucking caught the fish!