Skip to content

Instantly share code, notes, and snippets.

@maykonmeier
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maykonmeier/39f87d90dd992e225558 to your computer and use it in GitHub Desktop.
Save maykonmeier/39f87d90dd992e225558 to your computer and use it in GitHub Desktop.
Array and Object type
<?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