我有PHP的问题,我只想尝试调用方法
我收到了错误:
致命错误:允许的内存大小为134217728字节耗尽(尝试过 分配1个字节) 第13行的C:\ xampp \ htdocs \ aa-acc \ include \ Produk_Method.php
我试过这个答案: Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php
我仍然会收到此错误:
致命错误:内存不足(已分配1881931776)(试图分配 65488字节)在C:\ xampp \ htdocs \ aa-acc \ include \ Produk_Method.php上 第13行
这是我的代码:
on 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>
Class 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';
}
?>
Class 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);
}
}
?>
制作DataAccess
<?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){
}
}
?>
有人可以帮帮我吗? 谢谢
答案 0 :(得分:4)
您的GetProdukCategory
方法调用自身,导致永无止境的递归。过了一会儿PHP耗尽了内存,试图为每个条目分配堆栈到函数中,你得到上面的错误。修复GetProdukCategory
中的代码以执行您希望它执行的操作(可能不是目前的操作)。