php-src/tests/classes/protected_001b.phpt

29 lines
543 B
Plaintext
Raw Permalink Normal View History

2003-02-06 07:07:24 +08:00
--TEST--
2003-08-09 22:48:47 +08:00
ZE2 A protected method can only be called inside the class
2003-02-06 07:07:24 +08:00
--FILE--
<?php
class pass {
2020-02-04 05:52:20 +08:00
protected function fail() {
echo "Call fail()\n";
}
2003-02-06 07:07:24 +08:00
2020-02-04 05:52:20 +08:00
public function good() {
$this->fail();
}
2003-02-06 07:07:24 +08:00
}
$t = new pass();
$t->good();
$t->fail();// must fail because we are calling from outside of class pass
echo "Done\n"; // shouldn't be displayed
?>
--EXPECTF--
Call fail()
Fatal error: Uncaught Error: Call to protected method pass::fail() from global scope in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d