<?php

class Test {
	public function foo() {
		function bar() {
			echo "Hello from bar!" . PHP_EOL;
		}
		
		echo "Hello from foo!" . PHP_EOL;
	}
}

$t = new Test;
// PHP Fatal error:  Call to undefined method Test::bar()
// $t->bar();

// Works, prints "Hello from foo!"
// bar() is now defined, but not where you expect
$t->foo();

// PHP Fatal error:  Call to undefined method Test::bar()
// $t->bar();

// Works, prints "Hello from bar!"
// Note that this is global scope, not from Test
bar();