Created
May 8, 2012 17:11
-
-
Save tufanbarisyildirim/2637464 to your computer and use it in GitHub Desktop.
private_calling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ | |
private static Program instance; | |
static void Main(string[] args) | |
{ | |
instance = new Program(); | |
instance.callMe(); | |
} | |
private void callMe() | |
{ | |
Console.WriteLine("Yeah! you can call me."); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Bar | |
{ | |
public $barObject; | |
public function createObject() | |
{ | |
$this->barObject = new Bar(); | |
} | |
public function callFoo() | |
{ | |
//foo is private! but i can call because I'm Bar! | |
$this->barObject->foo(); | |
} | |
private function foo() | |
{ | |
echo "Yes! foo is called."; | |
} | |
} | |
// Let's call | |
$bar = new Bar(); | |
$bar->createObject(); | |
$bar->callFoo(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment