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?

The same holds true for PHP for both variables and functions.

class SomeClass{
  private $test1;
  public $test2;
  private getTest1(){return $this->test1;}
  public getTest2(){return $this->test2;}
}

Then if you try to access them

$blah = new SomeClass();
$test1 = $blah->getTest1(); //error
$test2 = $blah->getTest2(); //works
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.