Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active December 20, 2017 10:30
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 tommcfarlin/48b39d7e5524dadf0037239fef07cc7c to your computer and use it in GitHub Desktop.
Save tommcfarlin/48b39d7e5524dadf0037239fef07cc7c to your computer and use it in GitHub Desktop.
[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