问题描述
这是一个经常讨论的问题,但到目前为止,似乎还没有解决我的问题. 我正在使用$ pdf = new fpdf()生成PDF; .这很好.但是现在我想拥有一个页码的页脚.在尝试了很多事情之后,我发现了,如果您想设置页脚,则需要使用$ pdf = new yourpdfclassname()创建一个实例; (扩展了父型FDF类).
再次运行整个过程,我会收到错误:允许的内存大小为33554432字节耗尽(尝试分配77个字节)在/..blabla/yourpdfclassname.php in Line 16
>有人知道当我打电话给孩子课时会发生这个错误吗?我的意思是它与父班一起使用...和BTW,77字节比33554432字节小得多...嗯
class REPORTSPDF extends FPDF { .... } 16: $pdf = new REPORTSPDF();
第16行在ReportSpdf的构造函数中.第16行之前没有其他行.当$ pdf = new Reportspdf()被调用时,它只是崩溃.
没有页脚函数我有相同的错误.奇怪的是,当我将第16行更改为
时$pdf = new FPDF();
一切正常(除了我没有页脚的例外).
推荐答案
听起来您的代码中有一个无限循环.尝试做一个简单的Hello-World测试,看看会发生什么并检查代码中的所有循环.
其他推荐答案
增加内存限制
有3种增加内存限制的方法
-
使用配置文件
更改php.ini中的内存限制
memory_limit = 32m
-
使用php
ini_set('memory_limit','32m');
-
使用htaccess
php_value memory_limit 32m
不同服务器中的方法
共享托管
php_value memory_limit 32M
专用或VPS优化
ssh -lroot domain.com locate php.ini vi /usr/local/php/etc/php.ini edit to memory_limit=32M; save file httpd restart /sbin/service httpd restart
其他推荐答案
错误消息意味着,在尝试分配附加 77字节时,超过了33554432字节的内存限制.
围绕以下方式只有两种方式:要么优化子类中的代码,因此您不需要太多的内存,或者增加了php.ini中的内存限制(或使用等效方法来操纵PHP配置).
问题描述
This is a often discussed issue but so far no solution seems to fit for my problem. I'm generating a pdf with $pdf = new FPDF(); . This works fine. But now I want to have a footer with the page number. After trying a lot of things I found out, that if you want to set a footer, you need to create an instance with $pdf = new yourPDFclassName(); (which extends the parent FDF class).
Running the whole thing again I receive the error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 77 bytes) in /..blabla/yourPDFclassName.php on line 16
Does anyone have an idea why this error occurs when I call the child class? I mean it works with the parent class... And btw, 77 bytes are much smaller than the 33554432 bytes ... hmm
class REPORTSPDF extends FPDF { .... } 16: $pdf = new REPORTSPDF();
The line 16 is in the constructor of REPORTSPDF. There are no other lines before line 16. It just crashes when $pdf = new REPORTSPDF() is called.
Without the Footer function I have the same error. The weird thing is that when I change line 16 to
$pdf = new FPDF();
everything works fine (with the exception that I don't have a footer).
推荐答案
sounds like you have an infinite loop in you code. try to do a simple hello-world-test ans see what happens and check all loop in your code.
其他推荐答案
Increase memory limit
There are 3 ways to increase memory limit
using config file
Change memory limit in php.ini
memory_limit = 32M
using PHP
ini_set('memory_limit','32M');
using htaccess
php_value memory_limit 32M
Methods in different server
Shared Hosting
php_value memory_limit 32M
Dedicated or VPS Optimized
ssh -lroot domain.com locate php.ini vi /usr/local/php/etc/php.ini edit to memory_limit=32M; save file httpd restart /sbin/service httpd restart
其他推荐答案
The error message means that, while attempting to allocate an additional 77 bytes, the memory limit of 33554432 bytes was exceeded.
There are only two ways around this: either optimize the code in your subclass so you don't need as much memory, or increase your memory limit in php.ini (or using equivalent methods for manipulating with the PHP configuration).