SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 54 | Next

Hasin Hayder

"Object-Oriented Programming with PHP5"


For example see the code below:
class Overloader
{
function __call($method, $arguments)
{
echo "You called a method named {$method} with the following
arguments
";
print_r($arguments);
echo "
";
}
}
$ol = new Overloader();
$ol->access(2,3,4);
$ol->notAnyMethod("boo");
?>
Kick-Starting OOP
[ 42 ]
If you see the code above, then you will see that there is no method called access
and notAnyMethod. So therefore, it should raise an error, right? However, the
method overloader still helps you to call any non existing method. If you execute the
code above, you will get the following output.
You called a method named access with the following arguments
Array
(
[0] => 2
[1] => 3
[2] => 4
)
You called a method named notAnyMethod with the following arguments
Array
(
[0] => boo
)
That means you will get all arguments as an array. There are many more magic
methods, which you will learn step-by-step in this book.
Visually Representing a Class
In OOP, sometimes you have to visually represent your class. Let's learn how to
visually represent a class. For this, we will use our Emailer class this time.
class Emailer
_construct($sender)
addRecipients($resc)
setSubject($subject)
setBody($body)
sendEmail()
$sender
$recipient
$subject
$body
In this graphical representation, there are three sections.


Pages:
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6