Howdy ;)
1. Use brackets after the object name when creating new stuff: new object
();
2. I see a lot of incorrect string concatenation -- well it's not correct, but it's also not efficient either: use the operand .=, like such:
PHP Code:
// BAD: $table_string = $table_string."</table>";
$table_string .= '</table>';
3. You should consider using single quotes for the simple fact that there's a slight performance increase when doing so. When using double quotes PHP checks for variables contained inside those quotes. The performance gain is trivial, but it's worth noting.
4. It would be more logical to use count() or sizeof() (same functions) in your "bHeadings" function instead of incrementing the head_count in the foreach:
PHP Code:
$this->head_count += count($table_headings);
// instead of: ++$this->heading_count;
4. Utilize the === operand. It's an identical-comparison operand, it's actually a lot faster than == than you would expect. Use it wisely.
PHP Code:
// Since count() will always return an int, it's safe to use ===
if(count($row) === $this->heading_count)
6. When you initialize your variables, set their values. There is no performance loss from this, and other languages actually benefit from it (not sure if PHP benefits from it, but it's still a good habit). This makes for good practice, and avoids possible type-confusion. For example:
PHP Code:
private $heading_count = 0;
// Instead of private $heading_count;
// This way the type is instantly an integer, and not considered null, which is not an int.
7. Use lower-case when typing keywords. There's actually a performance gain when doing this, although trivial, it's still worth noting. Also, in my opinion lowercase keywords are much prettier!
PHP Code:
//**************************
$key = null; // looping key
$row = null; // looping value(is an array)
$key2 = null; // looping key
$val2 = null; // looping value
//**************************
8. Utilize the !== operand, it works the same way === does, regarding comparison.
PHP Code:
// Bad: if($this->error != NULL)
if($this->error !== null)
----
Also, your singleton method.. I think it could use a touch-up, using __construct of course:
PHP Code:
public static $CreateTable = null;
public function __construct()
{
self::$CreateTable = &$this;
}
static public function getInstance()
{
if(self::$CreateTable === null)
{
new self();
}
return self::$CreateTable;
}
I hope I've help a little.. :)
-Jay