Reputation: 690
i have a problem with PHP i just want try to call method
i got error :
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1 bytes) in C:\xampp\htdocs\aa-acc\include\Produk_Method.php on line 13
and i have tried this answer : Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php
and i still get this error:
Fatal error: Out of memory (allocated 1881931776) (tried to allocate 65488 bytes) in C:\xampp\htdocs\aa-acc\include\Produk_Method.php on line 13
this is my code:
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();
?>
Class Variable
<?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);
}
}
?>
Produk 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){
}
}
?>
Can Someone help me?? thank you
Upvotes: 1
Views: 2239
Reputation: 52792
Your GetProdukCategory
method calls itself, resulting in a never-ending recursion. After a while PHP runs out of memory trying to allocate the stack for each entry into the function, and you get the error above. Fix the code in GetProdukCategory
to do what you want it to do (probably not what it does at the moment).
Upvotes: 4