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

BOHAN ZHANG
BOHAN ZHANG
4,446 Points

PHP code not through OOP

Extending from a parent class allows the child to inherit all attributes and abilities of the parent. Step 1: Add a new method to the Developer class named displayUserSkills. Step 2: Use the 'name' from the PARENT class, and the 'skills' from the CURRENT class, to replace the <PLACEHOLDERS> and RETURN following string (NOTE that skills separated with a comma and space): <NAME> has the following skills: <SKILL1>, <SKILL2>, <SKILL3> Example Output: Alena has the following skills: PHP, MySQL, HTML

my code so far:

<?php

//add new child class here class Developer extends User { protected $skills = array();

public function getSkills(){ return $this->skills; }

public function setSkills($an_array){ $this->skills = $an_array; }

public function displayUserSkills(){ return $this -> getSkills();

}

}

$an_array = array("PHP","MySQL","HTML");

$stuff = new Developer ;

$stuff -> setSkills($an_array);

$stuff -> setName('Alena');

echo $stuff->getName() . " has the following skills: " . implode(', ', $stuff->displayUserSkills());

?>

Out put error;

Alena has the following skills: PHP, MySQL, HTMLPHP Warning: strtolower() expects parameter 1 to be string, array given in 37235294-194c-4d9b-943d-c20e202f54c4.php on line 224 Warning: strtolower() expects parameter 1 to be string, array given in 37235294-194c-4d9b-943d-c20e202f54c4.php on line 224

anyone knows why?

1 Answer

The key lies in "Warning: strtolower() expects parameter 1 to be string, array given in 37235294-194c-4d9b-943d-c20e202f54c4.php on line 224"

Your error exists in a different part of the code that you don't have listed here. Find wherever your strtolower() function exists and check to see whats being fed into it.