TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Class-Object visibility through Properties-Methods Access Modifiers (http://www.talkphp.com/advanced-php-programming/4887-class-object-visibility-through-properties-methods-access-modifiers.html)

sohdubom 08-21-2009 04:16 PM

Class-Object visibility through Properties-Methods Access Modifiers
 
::Class-Object visibility through Properties-Methods Access Modifiers

In PHP, is it correct to say that we control Class-Object visibility by setting the correct Access Modifier to its properties and methods? eg. In PHP, classes are public, we can't declare a private nor protect class (we can use final and abstract, for other purposes)

Thanx in advance :-)

ioan1k 08-21-2009 04:28 PM

I don't really understand what you are saying ... but

A class has optional definitions that are final or abstract that specify specific functionality
Read more about this at http://us3.php.net/manual/en/language.oop5.basic.php

Properties and methods defined in a class wither it is public, private or protected have no influence on visibility of the class itself you can read more about this at
http://us3.php.net/manual/en/languag...visibility.php

Enfernikus 08-21-2009 04:33 PM

Yes this is correct, we can not scope an object in PHP as we don't have Namespaces till PHP6. ( Correct me if I'm wrong )

sohdubom 08-21-2009 05:19 PM

Quote:

Originally Posted by ioan1k (Post 28021)
I don't really understand what you are saying ...

I'm talking about Encapsulation and Data Hiding, where Encapsulation is the ability to group attributes and methods inside a single class/object and Data Hiding is the ability to access control to class data(attributes) and methods from external users(other objects) ... as rule of thumb, access to class/objects functionalities should be done through its public interfaces, aka public methods ... attributes should all be private/protected for good Data Hiding to work ... obs. class's public interfaces not to be confused to the class construct named <<Interface>>

I'm new to PHP, but not to OO so I'm checking to see if my post regarding Encapsulation and Data Hiding in PHP was right ... I think so ... according to 'Enfernikus' last post

Salathe 08-21-2009 05:40 PM

Quote:

Originally Posted by Enfernikus (Post 28022)
… we don't have Namespaces till PHP6. ( Correct me if I'm wrong )

Namespaces came with 5.3 ^^

Enfernikus 08-21-2009 05:44 PM

Really!? I'm going to go have some fun now...

Salathe 08-21-2009 06:11 PM

Quote:

Originally Posted by Enfernikus (Post 28025)
Really!? I'm going to go have some fun now...

Really! Now I can use TalkPHP\Members\Efernikus as Slave; 8-)

Enfernikus 08-21-2009 06:23 PM

Quote:

Originally Posted by Salathe (Post 28027)
Really! Now I can use TalkPHP\Members\Efernikus as Slave; 8-)

Touché! We'll have a Gladiator type going of things I suspect.

( Movie - Russel Crowe )


All times are GMT. The time now is 07:48 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0