•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 332,564 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,108 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 91 | Replies: 1
![]() |
•
•
Join Date: Feb 2008
Location: Ottawa, Ontario
Posts: 15
Reputation:
Rep Power: 1
Solved Threads: 2
I have noticed that some people use public/ private for their vars and functions. I tried looking it up on php.net and then here, but only found one explanation of it on the C++ board. It says that if you declare private var then it is only accessible by that class and public is by everyone.. does the same hold true in php? and what about when someone declares private/ public function?
•
•
Join Date: Apr 2005
Location: New York state
Posts: 403
Reputation:
Rep Power: 5
Solved Threads: 54
The same holds true for PHP for both variables and functions.
Then if you try to access them
php Syntax (Toggle Plain Text)
class SomeClass{ private $test1; public $test2; private getTest1(){return $this->test1;} public getTest2(){return $this->test2;} }
php Syntax (Toggle Plain Text)
$blah = new SomeClass(); $test1 = $blah->getTest1(); //error $test2 = $blah->getTest2(); //works
Quote by AncientDragon:
Requests for help via PM will just be ignored. Post your questions in one of the technical boards and you will get an answer from someone.
And I WILL NOT DO YOUR HOMEWORK!
Requests for help via PM will just be ignored. Post your questions in one of the technical boards and you will get an answer from someone.
And I WILL NOT DO YOUR HOMEWORK!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
- public vs private (Java)
- Java or PHP? (IT Technologies and Trends)
- PHP, ASP, ColdFusion, what's your fav? (IT Technologies and Trends)
- Features in PHP 5 (PHP)
- embPerl or PHP (Perl)
Other Threads in the PHP Forum
- Previous Thread: phpbb3
- Next Thread: Initialization of an Array


Linear Mode