Skip to content

Instantly share code, notes, and snippets.

@ReinierC
Last active January 5, 2018 09:21
Show Gist options
  • Save ReinierC/2c53acb0b99b8ada7891a02149b2d3c7 to your computer and use it in GitHub Desktop.
Save ReinierC/2c53acb0b99b8ada7891a02149b2d3c7 to your computer and use it in GitHub Desktop.
PHP OOP Get/Send
<?php
include 'users.inc.php';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP OOP Get/Send</title>
<style>
p {
font-size: 12px;
}
.alert {
color: red;
}
</style>
</head>
<body>
<h2>OOP getFunction, sendFunction</h2>
<br>
<?php
$users = new Users('John', 'Doe', 'Blond', 'Grey', 'Male');
$users2 = new Users('Jane', 'Does', 'Red', 'Green', 'Female');
?>
<br>
<?php echo $users->fullName(); ?>
<?php echo $users->userStats(); ?>
<br>
<?php echo $users2->fullName(); ?>
<?php echo $users2->userStats(); ?>
</body>
</html>
<?php
class Users {
//Properties and Methods go here
public $first; //properties we'll have at some point
public $last;
public $hairColor;
public $eyeColor;
public $userSex;
public function __construct($firstName, $lastName, $hairColorUser, $eyeColorUser, $userSexUser) {
$this->first = $firstName;
$this->last = $lastName;
$this->hairColor = $hairColorUser;
$this->eyeColor = $eyeColorUser;
$this->userSex = $userSexUser;
}
public function fullName() {
return "User Name <br>". $this->first. " ". $this->last. "<br>";
}
public function userStats() {
return "User Stats <br>hair: ". $this->hairColor. "<br>eye color: ". $this->eyeColor. "<br>sex: ". $this->userSex. "<br>";
}
public function __destruct() {
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment