Followed the Project Instructions - Code Did Not Work As Expected

I have been working on this project for approximately a day now, and I am still struggling to solve the 7th part. Although I am not certain if I made any errors, my code is not providing the output I need.
Code:

<?php class StringUtils { public static function secondCase($string){ $string = strtolower($string); $string[1] = strtoupper($string[1]); if(strlen($string) >= 2){ $string[1] = strtoupper($string[1]); }; return $string; } } class Pajamas { private $owner, $fit, $color; function __constructor( $owner = "Unclaimed", $fit = "great", $color = "silver" ){ $this->owner = StringUtils::secondCase($owner); $this->fit = $fit; $this->color = $color; } public function describe() { return "{$this->owner} owns a {$this->color} PJ with a fit of {$this->fit}."; } } $chicken_PJs = new Pajamas("CHICKEN", "regular", "green"); echo $chicken_PJs->describe();

//Expected Output: cHicken owns green PJs with a fit of regular.


Project: Going To Bed

https://www.codecademy.com/paths/php-skill/tracks/php-classes-and-objects/modules/learn-php-classes-and-objects-in-php/projects/php-going-to-bed

Does anyone know how to solve this???

should be __construct instead of __constructor. if you change it, it will work.

When in doubt, always reference documentation for the language: https://www.php.net/manual/en/language.oop5.decon.php

1 Like

Im used to Javascript, in JavaScript it is constructor. Thank you for clearing that up.