类中的PHP调用类返回错误

类中的PHP调用类返回错误

本文介绍了类中的PHP调用类返回错误:500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难在另一个类中新建一个类。
这是设置示例:



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(){
returnHello
}
} b $ b?>

Chrome返回:
HTTP错误500(内部服务器错误):遇到意外情况

解决方案



/ div>

将此代码添加到代码顶部

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

正确的PHP错误将显示或swtich它在您的 PHP。 ini设置


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?

解决方案

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

这篇关于类中的PHP调用类返回错误:500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 13:01