954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

SplFixedArray

My script is dies at the start when I try to devine a SplFixedArray and I don't know how to find the error. Help would be appreciated...

<?
        error_reporting( E_ALL ); 
        // Initialize the array with a fixed length
        $array = new SplFixedArray(5);

Thanks!
WBR

rouse
Junior Poster
114 posts since Dec 2007
Reputation Points: 10
Solved Threads: 1
 

I tried it and I had the same problem. I checked php.ini and I had the extension disabled (php_spl_types.dll) so I changed that but it still didn't work. I checked and the extension is in the Ext directory. It should work but it is still giving the same error.

chrishea
Nearly a Posting Virtuoso
1,428 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

Are you able to generate an error message of some kind, if so how?

rouse
Junior Poster
114 posts since Dec 2007
Reputation Points: 10
Solved Threads: 1
 

Two things immediately jump to mind, are short php start tags enabled? Also are you using a version of php > 5.3.0?

mschroeder
Work Harder
Team Colleague
666 posts since Jul 2008
Reputation Points: 279
Solved Threads: 131
 

In my case (since it isn't working for me either), I changed the short open tag when I tried it. I am running PHP 5.2.10 but my understanding is that it should still run.

According to PHP.net
This extension is available and compiled by default in PHP 5.0.0.
As of PHP 5.3.0 this extension can no longer be disabled and is therefore always available.

chrishea
Nearly a Posting Virtuoso
1,428 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

I'm running 5.2.8. I also set shorto_open_tag to Off, but that was of no value.
I am moving up to 5.3 now but as "chrishea" pointed out the docs say it should work with 5.0.0

rouse
Junior Poster
114 posts since Dec 2007
Reputation Points: 10
Solved Threads: 1
 

All of the documentation indicates that SplFixedArray methods have a >= 5.3.0 requirement. Works without issue on 5.3.5 and 5.3.6 here.

mschroeder
Work Harder
Team Colleague
666 posts since Jul 2008
Reputation Points: 279
Solved Threads: 131
 

PHP 5.2.11 on Win.

Defined classes prefixed with "Spl" are:

SplFileInfo
SplFileObject
SplTempFileObject
SplObjectStorage

When enabling php_spl_types extension:

SplType
SplEnum
SplBool
SplInt
SplFloat

are added.

I'm using this to get the classes:

$classes = get_declared_classes();
foreach($classes as $class) {
   if (strpos($class, 'Spl') !== false) echo $class . "\n"; 
}


It looks like 'SplFixedArray' isn't included before 5.3.0?

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

Digital-Ether: Your approach to determining the answer is very intelligent. Should have thought of doing something like that (but of course, I didn't!). Good work.

chrishea
Nearly a Posting Virtuoso
1,428 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

Digital-Ether:
Thanks for your help.

As a not so side note for me, I cannot seem to get version 5.3 of PHP running on my machine, so I will start a new note.

rouse
Junior Poster
114 posts since Dec 2007
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You