Scoping functions in PHP

From: Date: Wed, 10 Apr 2002 03:43:15 +0000
Subject: Scoping functions in PHP
Groups: php.general 
Request: Send a blank email to php-general+get-92338@lists.php.net to get a copy of this message
I am a Java programmer learning PHP. In Java you can have a class that contains public and private functions. Only the public functions are accessible outside of the class. Does PHP have a way to hide functions within a class (i.e. make the private)? My concern is that there are some functions that you don't want anyone being able to call...only local functions within the same class should be able to call it. I'll give an example below: <?php // myClass.php3 class myClass { function f1 // I want this one to be public { f2(); } function f2 // I want this one to be private {} } ?> <?php include 'myClass.php3'; $p = new myClass(); $p->f1(); // I want this to be a valid function call $p->f2(); // I want this to be an invalid function call ?> Any help would be greatly appreciated. Eric Starr

« previous php.general (#92338) next »