2
Follow the original code:
class Table{
private static $table;
public static function draw( stdData $data ){
self::$table = new self;
return self::$table->_draw( $data );
}
...
I made this modification below to try to dodge a possible problem with memory:
class Table{
private static $table;
public static function draw( stdData $data ){
self::$table = new self;
$html = self::$table->_draw( $data );
unset(self::$table);
return $html;
...
But it caused trouble:
Fatal error: Attempt to unset static property Table::$table in Table.php on line 8
Does the original code cause any memory problems? What would be the correct way to get out of the problem?
That is, it occupies space in memory unnecessarily?
The goal is to use at another time echo Table::draw($data);
to print a table and that after use have nothing in memory because of that.
What kind of memory problem are we talking about? I don’t know if this code makes any sense, since it doesn’t have a larger context.
– Maniero
I want to minimize memory usage as much as possible, in case free the memory that would be in
self::$table
. The class only generates a table html according to what is in$data
.– lino4000
you came to measure memory consumption?
– rray