private scope - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of private scope.php
- <?php
- class Foo {
- private function baz() {
- echo 'Foo::baz()' . "\n";
- }
- public function callBaz() {
- $this->baz();
- }
- public static function callBazWith(Foo $foo) {
- $foo->baz();
- }
- }
- $f = new Foo();
- try {
- $f->baz();
- } catch (Error $e) {
- echo '$f->baz(): ' . $e->getMessage() . "\n";
- }
- try {
- $f->callBaz();
- } catch (Error $e) {
- echo '$f->callBaz(): ' . $e->getMessage() . "\n";
- }
- try {
- Foo::callBazWith($f);
- } catch (Error $e) {
- echo 'Foo::callBazWith($f): ' . $e->getMessage() . "\n";
- }
File Description
- private scope
- PHP Code
- 14 Dec-2018
- 538 Bytes
You can Share it:
Latest PHP Pastes