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 30 | Next

Hasin Hayder

"Object-Oriented Programming with PHP5"

We must note
some things before using an object. You must initiate an object before using it. After
initiating, you can access all its public properties and methods using "->" after the
->" instance. Let's see using the following code:
$emailerobject = new Emailer("hasin@pageflakes.com");
$emailerobject->addRecipients("hasin@somewherein.net");
$emailerobject->setSubject("Just a Test");
$emailerobject->setBody("Hi Hasin, How are you?");
$emailerobject->sendEmail();
?>
Kick-Starting OOP
[ 22 ]
In the above code piece, we first created an instance of Emailer class to a variable
name $emailerobject in the first line. Here, there is something important to note:
We are supplying a sender address while instantiating this:
$emailerobject = new Emailer("hasin@pageflakes.com");
Remember we had a constructor method in our class as __construct($sender).
When initiating an object, we said that the constructor method is called
automatically. So while initiating this Emailer class we must supply the proper
arguments as declared in the constructor method. For example the following code
will create a warning:
$emailer = new emailer();
?>
When you execute the above code, it shows the warning as follows:
Warning: Missing argument 1 for emailer::__construct(),
called in C:\OOP with PHP5\Codes\ch1\class.


Pages:
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6