Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin

tommcfarlin/00-Message.php Secret

Last active Dec 20, 2017
Embed
What would you like to do?
[OOP Fundamentals] Two Pillars of Object-Oriented Programming: Part 2 of 2
<?php
class Message
{
public function send()
{
echo "This message is sent from the Message class.\n";
}
public function receive()
{
echo "This message was received from the Message class.\n";
}
}
<?php
class SMSMessage extends Message
{
public function send()
{
echo "This message is sent from the SMSMessage class.\n";
}
}
<?php
$message = new Message();
$message->send();
$message->receive();
<?php
$message = new SMSMessage();
$message->send();
$message->receive();
<?php
class Message
{
public function send()
{
echo "This message is sent from the Message class.\n";
}
public function receive()
{
echo "This message was received from the Message class.\n";
}
}
class SMSMessage extends Message
{
public function send()
{
echo "This message is sent from the SMSMessage class.\n";
}
}
$message = new Message();
$message->send();
$message->receive();
$message = new SMSMessage();
$message->send();
$message->receive();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment