OO in ASP.NET and PHP

I won’t spend much time on explaining Object Oriented Programming as there already million of words have been written by the experts and few of them are really worth reading (to name a few, I presently read Pter Lavin’s book on OO in PHP finding it simply brilliant.).
What I just try to do is very simple, find a simmilarity between creating ‘Class’ in ASP.NET and PHP and using access modifiers I set their properties from private to public.
First, let me show how Class being written in ASP.NET
Let me crate a class called Person

//creting class
class Person
{
private _name;
public Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
}
//crating instance
Person person1 = new Person();
person1.Name = “Person1’s Name”;
Response.Write(“Person1’s Name is ” + person1.Name);

Next in PHP I follow the same procedure

And the page looks like this:

The thing is, I tried to keep codes of both great dynamic web language almost similar. So that one can follow the simmilarity between those get and set properties that make private variables public so that you can ultimately access them in different class, in different situation.
Hope, curious people find it interesting.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s