Skip to content

Instantly share code, notes, and snippets.

@tufanbarisyildirim
Created May 8, 2012 17:11
Show Gist options
  • Save tufanbarisyildirim/2637464 to your computer and use it in GitHub Desktop.
Save tufanbarisyildirim/2637464 to your computer and use it in GitHub Desktop.
private_calling
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.");
}
}
}
<?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