#61 Compile error in PHP 5.2 when used as object

open
nobody
None
5
2012-10-10
2010-11-11
No

I get compiler erros in PHP 5.2 when using this as an object.

The offending lines are 609 and 940, which both contain this construct:

    if ($this->size>0) $this->char = $this->doc[0];

This tries to get the first character of $this->doc, but PHP 5.2 sees it as trying to access it as an array.
It's easily fixed by this:

    if ($this->size>0) $this->char = substr($this->doc, 0, 1);

Or you could probably use chr(ord($this->doc)) as well.
Either way solves the compile error without changing functionality.

Discussion