...

/

Solution Review: Access Modifiers

Solution Review: Access Modifiers

Let's look at the solution to the Access Modifiers challenge.

We'll cover the following...

Solution

Press + to interact
<?php
class User {
private $firstName;
public function setFirstName($str){
$this -> firstName = $str;
}
public function getFirstName(){
return $this -> firstName;
}
}
function test()
{
$user1 = new User();
$user1 -> setFirstName("Joe");
return $user1 -> getFirstName();
}
echo test();
?>

Explanation

...