What is encapsulation with simple example in php?
Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation. Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object. Encapsulation is like your bag in which you can keep your pen, book etc. It means this is the property of encapsulating members and functions.
0) $mark = 10; else $mark = 0; }
}
}
?>
I am giving an another example of real life (daily use) that is “TV operation”. Many peoples operate TV in daily life.
It is encapsulated with cover and we can operate with remote and no need to open TV and change the channel. Here everything is in private except remote so that anyone can access not to operate and change the things in TV.