Guest User

Untitled

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2. require("c.php");
  3.  
  4. /*
  5. // From C.php
  6.  
  7. class C
  8. {
  9. private $cVar;
  10.  
  11. __construct(){
  12. }
  13.  
  14. public function method()
  15. {
  16. echo "some text";
  17. }
  18. }
  19. */
  20.  
  21. class A
  22. {
  23. protected $var1; // C Object
  24.  
  25. public function __construct()
  26. {
  27. $this->var1 = new C();
  28. }
  29.  
  30. function methodA()
  31. {
  32. $this->var1->method();
  33. }
  34. }
  35.  
  36. class B extends A
  37. {
  38. public function __contruct(){
  39. }
  40. }
  41.  
  42. $var = new B();
  43. $var->methodA();
  44.  
  45. //Fatal error: Call to a member function method() on a non-object...
  46. ?>
Add Comment
Please, Sign In to add comment