[ create a new paste ] login | about

Link: http://codepad.org/BwBmveIt    [ raw code | output | fork ]

PHP, pasted on Jul 29:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
class Person{
public $isAlive = true;
public $firstname;
public $lastname;
public $age;
public function __construct($firstname,$lastname,$age){
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->age = $age;
}
public function greet(){
return "Olá, meu nome é " . $this->firstname . " " . $this->lastname . ". Prazer em conhecê-lo!";
}
}
$teacher = new Person("boring","12345",12345);
$student = new Person("Anderson","teste",100);
echo $teacher->greet();
echo '<br>';
echo $student->greet();
?>


Output:
1
Olá, meu nome é boring 12345. Prazer em conhecê-lo!<br>Olá, meu nome é Anderson teste. Prazer em conhecê-lo!


Create a new paste based on this one


Comments: