Last active
August 29, 2015 14:04
-
-
Save maykonmeier/39f87d90dd992e225558 to your computer and use it in GitHub Desktop.
Array and Object type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Array | |
$fruits = array('Apple', 'Orange', 'Pineapple'); | |
// Array key-value | |
$data = array( | |
'first_name' => 'Maykon', | |
'last_name' => 'Meier', | |
'age' => 25 | |
); | |
var_dump($data); | |
// Object | |
class User | |
{ | |
private $firstName; | |
private $lastName; | |
public function __construct() | |
{ | |
$this->firstName = 'Default'; | |
$this->lastName = 'Noname'; | |
} | |
public function setName($name) | |
{ | |
$this->firstName = $name; | |
return $this; | |
} | |
} | |
$user = new User(); | |
$user->setName('Maria'); | |
var_dump($user); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment