Reputation: 11882
I am getting the following error ever since I upgraded from PHP 5.2x or 5.3x (not sure which) to 5.4x:
syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_VARIABLE
The following is the code that generates the error. Essentially I have a class to create SVG image with a static draw()
method defined in a derived class and a static helper function drawPng()
on the base class that converts the SVG to PNG using Imagick. The error is at the marked line.
static function drawPng($filename, $data, &$options=array()) {
ob_start();
static::draw($data, $options); // <-- Error occurs
$svg = ob_get_clean();
$im = new Imagick();
if(!$im) die('Imagick not installed');
$bg = (empty($options['background']) ? 'transparent' : $options['background']);
$im->setBackgroundColor(new ImagickPixel($bg));
$im->readImageBlob($svg);
$im->setImageFormat('png');
if($filename) $im->writeImage($filename);
else echo $im->getImageBlob();
}
The code as shown above has worked until the upgrade. Thanks for the assistance.
Upvotes: 1
Views: 217
Reputation: 1767
I think you messed up the PHP versions and actually starting this code on PHP 5.2. This error would happen in PHP 5.2 because there is no static:: access. Also the error message with T_PAAMAYIM_NEKUDOTAYIM in PHP 5.4 would mention "::", while yours doesn't, which is another hint that you're running wrong version of PHP.
To verify add echo phpversion(); exit(); to the top of this method.
Upvotes: 0
Reputation: 3588
T_PAAMAYIM_NEKUDOTAYIM
is the hebrew name (for some reason - Zend was started by Israelis folk, as ceejayoz pointed out. ) for the double colon, aka ::
Change static
to self
:
static::draw($data, $options);
self::draw($data, $options);
Upvotes: 3