当前位置: 首页 > 知识库问答 >
问题:

致命错误:允许的内存大小134217728字节已用尽(尝试分配24字节)

束敏学
2023-03-14

我有一个PHP的问题,我只是想尝试调用方法

我得到错误:

致命错误:允许的内存大小为134217728字节耗尽(试图分配1字节)在C:\xampp\htdocs\aa-acc\包括\Produk_Method.php在第13行

我尝试过这个答案:在php中允许内存大小为33554432字节(尝试分配43148176字节)

我仍然得到这个错误:

致命错误:内存不足(分配1881931776)(尝试分配65488字节)在第13行的C:\xampp\htdocs\aa-acc\包括\Produk_Method.php

这是我的代码:

关于Produk.php

<?php

if(!defined('access_include')){
    define('access_include', '..');
}
include( access_include . '/include/start_up.incl.php');
?>

<!DOCTYPE html>
<html>
<head>
<?php
    $HeadTag->keyword = $Variable->WEBNAME . ', ' . $Variable->WEBNAME2;
    $HeadTag->description = $Variable->DESCRIPTION;
    echo $HeadTag->head_admin('Produk', 'produk');
?>

</head>
<body>

$ProdukMethod->GetProdukGroup('1');

$ProdukMethod->GetProdukCategory('1');

?>
</body>
</html>

班级Start_up

if(!defined('access_include')){
    header('Location: index.php');
    exit;
}
date_default_timezone_set('Asia/Jakarta');
ini_set('memory_limit', '-1');
<?php
    include(access_include . '/include/class_variable.php');
    $Variable = new variable();

    include( access_include . '/include/head_metadata.incl.php');
    $HeadTag = new head_tag($Variable);

    include(access_include . '/include/Produk_Method.php');
    $ProdukMethod = new ProdukMethod();
?>

类变量

<?php
if(!defined('access_include')){
    header('Location: index.php');
    exit;
}

class variable{
    public $WEBHOST = 'http://localhost:8080/aa-acc/';
    public $WEBNAME = 'aa-acc';
    public $WEBNAME2 = 'Anugrah Abadi Accessories';
    public $DESCRIPTION = 'Description';

}
?>

类ProdukMethod

<?php
if(!defined('access_include')){
    header('Location: index.php');
    exit;
}
include(access_include . '/include/DataAccess.incl.php');
class ProdukMethod extends DataAccess{
    public function __construct(){

    }  
    public function GetProdukCategory($catname = ''){
        echo $this->GetProdukCategory($catname); //Error at this line
    }
    public function GetProdukGroup($groupname = ''){
        echo $this->GetProdukCategory($groupname);
    }
}

?>

Produk数据访问

<?php
if(!defined('access_include')){
    header('Location: index.php');
    exit;
}

class koneksi{
    private $HOSTNAME = 'localhost';
    private $USER = 'root';
    private $PASSWORD = '';
    private $DATABASE = 'aa-acc';

    protected function koneksi_sql(){
    $Condb = @new MySQLi($this->HOSTNAME, $this->USER, $this->PASSWORD, $this->DATABASE);
        $Condb->connect_errno and die ('Connect Failed : '.$Condb->connect_error);
        return $Condb;
    }
}

class DataAccess extends koneksi{
    private $ConDb;

    public function __construct(){
        $this->ConDb = $this->koneksi_sql();
    }

    protected function GetProdukCategory($catname){

    }
    protected function GetProdukGroup($groupname){

    }
}
?>

有人能帮我吗??非常感谢。

共有1个答案

郭乐湛
2023-03-14

你的方法调用自己,导致一个无休止的递归。一段时间后,PHP运行内存溢出,试图为函数的每个条目分配堆栈,然后您会得到上面的错误。修复代码中的代码,让它做你想让它做的事情(可能不是它现在做的事情)。

 类似资料: