Script keeps crashing...
Posted: Wed Dec 20, 2006 2:07 pm
Hey all,
I've been a long time lurker here, but this time I really need your help
The following script keeps crashing my server, I cannot figure out why, maybe some of you have an idea?
This was the class, now here is how i use it and how it works:
Now here is how I use it, and it crashes my server:
And I've also got an error log, if that is usefull:
Any input is greatly appreciated!
Thx!
I've been a long time lurker here, but this time I really need your help
The following script keeps crashing my server, I cannot figure out why, maybe some of you have an idea?
Code: Select all
<?php
class Template
{
protected $templateFile;
protected $data;
public function __construct($template, $data)
{
$this->data = $data;
$this->templateFile = $template;
}
public function getData()
{
return $this->data;
}
public function parse($data)
{
if(is_array($data) && count($data) > 0)
{
ob_start();
foreach($this->data as $var => $value)
{
if(is_a($value, 'Template'))
{
$$var = $this->parse($value->getData());
}
else
{
$$var = $value;
}
}
require $this->templateFile;
$parsed = ob_get_contents();
ob_end_clean();
return $parsed;
}
}
}
?>Code: Select all
$test = array("a" => 'abc', "b" => 'bac');
$tpl = new Template('library/view/html/test.php', $test);
echo $tpl->parse($tpl->getData());Code: Select all
$test2 = array('bla' => "hey", "what" => "frage");
$test = array("a" => 'abc', "b" => 'bac', "c" => new Template('library/view/html/test2.php', $test2));
$tpl = new Template('library/view/html/test.php', $test);
echo $tpl->parse($tpl->getData());Code: Select all
Thread 0 Crashed:
0 libphp5.so 0x0248b458 zend_mm_add_to_free_list + 208
1 libphp5.so 0x0248c824 _zend_mm_free_int + 1168
2 libphp5.so 0x0248d308 _efree + 56
3 libphp5.so 0x02461c54 php_end_ob_buffer + 1928
4 libphp5.so 0x02461d60 php_end_ob_buffers + 60
5 libphp5.so 0x0244a28c php_request_shutdown + 348
6 libphp5.so 0x0254fd4c php_apache_request_dtor + 32
7 libphp5.so 0x025504e0 php_handler + 1680
8 httpd 0x0000ac74 ap_run_handler + 100 (config.c:157)
9 httpd 0x0000b2e8 ap_invoke_handler + 248 (config.c:373)
10 httpd 0x00031c9c ap_process_request + 108 (http_request.c:258)
11 httpd 0x00031278 ap_process_http_connection + 120 (http_core.c:184)
12 httpd 0x0001efd4 ap_run_process_connection + 100 (connection.c:43)
13 httpd 0x0004f58c child_main + 1276 (prefork.c:641)
14 httpd 0x0004f750 make_child + 320 (prefork.c:739)
15 httpd 0x0004fed8 ap_mpm_run + 1672 (prefork.c:1036)
16 httpd 0x0000362c main + 3324 (main.c:717)
17 httpd 0x0000219c _start + 760
18 httpd 0x00001ea0 start + 48Thx!