note 110891 modified in language.oop5.visibility by danbrown

From: Date: Thu, 17 Jan 2013 15:33:50 +0000
Subject: note 110891 modified in language.oop5.visibility by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193159@lists.php.net to get a copy of this message
Interestingly enough, PHP does very reasonable job in regards to interaction between classes and plain functions (even ones defined in the same file as the class) <?php class Test { private function foo() { echo "Foo" . PHP_EOL; } protected function bar() { echo "bar" . PHP_EOL; } static function foobar($test) { $test->bar(); // works $test->foo(); // works } } function simple_function() { $test = new Test(); $test->bar(); // does not work $test->foo(); // does not work Test::foobar($test); // works } simple_function(); ?> --was-- Interestingly enough, PHP does very reasonable job in regards to interaction between classes and plain functions (even ones defined in the same file as the class) <?php class Test { private function foo() { echo "Foo" . PHP_EOL; } protected function bar() { echo "bar" . PHP_EOL; } static function foobar($test) { $test->bar(); // works $test->foo(); // works } } function simple_function() { $test = new Test(); $test->bar(); // does not work $test->foo(); // does not work Test::foobar($test); // works } simple_function(); http://php.net/manual/en/language.oop5.visibility.php

« previous php.notes (#193159) next »