PHP call class in class returns error:500 [closed]

2019-01-15 16:45发布

I'm having a hard time new a class in another class. This is an example of the setup:

index.php

<?php
   include("functions/userFunctions.php");

   $user = new UserFunctions ();
   $user->validate();
?>

UserFunctions.php

<?php
   include("../db/userDB.php");

   class UserFunctions extends UserDB
   {
       public function GetHello(){
          $this->DBHello();
       }
   }
?>

UserDB.php

<?php
   class UserDB
   {
       public function DBHello(){
          return "Hello"
       }
   }
?>

Chrome returns: HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

How can this not work?

1条回答
▲ chillily
2楼-- · 2019-01-15 17:36

Add this to the top of your code

error_reporting(E_ALL);
ini_set("display_errors","On");

The right PHP errors would be displayed or swtich it on in your PHP.ini settings

查看更多
登录 后发表回答