User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Feb 2008
Location: Ottawa, Ontario
Posts: 15
Reputation: mom_of_3 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 2
mom_of_3's Avatar
mom_of_3 mom_of_3 is offline Offline
Newbie Poster

public/private in php

  #1  
7 Days Ago
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 403
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 54
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: public/private in php

  #2  
7 Days Ago
The same holds true for PHP for both variables and functions.
  1. class SomeClass{
  2. private $test1;
  3. public $test2;
  4. private getTest1(){return $this->test1;}
  5. public getTest2(){return $this->test2;}
  6. }
Then if you try to access them
  1. $blah = new SomeClass();
  2. $test1 = $blah->getTest1(); //error
  3. $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!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:53 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC