Questions tagged [spl]

SPL is a collection of PHP interfaces and classes that are meant to solve standard problems. This tag is not to be confused with the [shakespeare-lang] tag for Shakespeare Programming Language

SPL stands for Standard PHP Library. It is a collection of PHP interfaces and classes that are meant to solve standard problems. It contains a large set of predefined iterators, data-structures, interfaces and exceptions that can be used and extended.

Documentation can be found here. It is available by default from PHP 5.0.0 onwards.

365 questions
0
votes
2 answers

Using foreach with SplFixedArray

It seems like I can't iterate by reference over values in an SplFixedArray: $spl = new SplFixedArray(10); foreach ($spl as &$value) { $value = "string"; } var_dump($spl); Outputs: Fatal error: Uncaught exception 'RuntimeException' with message…
Desmond Hume
  • 8,037
  • 14
  • 65
  • 112
0
votes
1 answer

Is SplFixedArray implemented in C/C++ under the hood?

I'm not very familiar with the source code behind the entity we know as PHP, so I don't know whether the SPL library in general and SplFixedArray in particular are implemented in C/C++. Would anyone have the information?
Desmond Hume
  • 8,037
  • 14
  • 65
  • 112
0
votes
1 answer

Get specific files in a Recursive Directory

Following a given example by a comment in the php.net manual I am trying to grab each file named file.txt in a recursively directory structure. Folder/ subfold1 subfold2 file.txt subfold3 file.txt etc. is a example on how the…
John
  • 2,900
  • 8
  • 36
  • 65
0
votes
1 answer

Moving to PHP5 SPL

After not really working with PhP for a long time, I am moving into php 5 territory. One of the things I am now trying to figure out, is how to use spl autoload functionality. And before I make stupid beginners errors, could you please confirm /…
Jelle Ferwerda
  • 1,254
  • 1
  • 7
  • 13
0
votes
1 answer

RecursiveFilterIterator: how to not accept objects, but still visit their children?

I'm having difficulty to get RecursiveFilterIterator to visit children of objects that I don't want to accept, without also returning the unacceptable object. I have two types of Node objects: NodeTypeA and NodeTypeA, that both extend abstract type…
Decent Dabbler
  • 22,532
  • 8
  • 74
  • 106
0
votes
1 answer

PHP optimization with class

I have a project in codeigniter but isn't releveant. I have to search inside many external server cars with some search criteria like (sell zone, price, model...). I make a query in xml to some external server that response to me with an xml, now I…
Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
0
votes
1 answer

PHP RecursiveIteratorIterator: The system cannot find the path specified?

I have this error when I want to autoload classes with RecursiveIteratorIterator and spl_autoload_register, uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(): The system cannot find the path…
Run
  • 54,938
  • 169
  • 450
  • 748
0
votes
1 answer

Diffie-Hellman using Casper

I have an assignment to model the Diffie-Hellman Key exchange protocol using Casper (in a .spl file). I got the basics down and am finding it really hard to come up with the correct protocol desciption (#Protocol description). I searched…
0
votes
0 answers

Does PHP's spl_autoload_register Load Only Necessary Classes?

I've found numerous stackoverflow pages claiming that spl_autoload_register only loads necessary classes (__autoload vs include family for example), but is there documentation or proof of this? I checked php.net and couldn't find anything in their…
Josh Davis
  • 157
  • 3
  • 10
0
votes
1 answer

What's wrong with my autoloader?

I'm trying to register a few autoloaders and I get an HTTP 500. My error log says the following: [05-Aug-2013 04:32:38 UTC] PHP Fatal error: Uncaught exception 'LogicException' with message 'Function 'Autoloader::config' not callable…
Aaron
  • 95
  • 12
0
votes
1 answer

RecursiveIteratorIterator and nested RecursiveArrayIterators

I've been messing with RecursiveArrayIterators for handling nested objects as trees. The following code is bothering me as the result is returning only some of the values I'm expecting. Mainly, the root node seems to never be iterated over. I…
CVEEP
  • 441
  • 4
  • 12
0
votes
0 answers

Namespaced class is not autoloaded

I'm autloading my class in PHP with spl_autoload_register. This has been working fine for me so far. I have a site running on both Windows and a Linux server with no problems. But now i'm trying to setup my framework on a different Linux server…
Vivendi
  • 20,047
  • 25
  • 121
  • 196
0
votes
2 answers

SplMinHeap and top

I'm trying to extend PHP's SplMinHeap so I can limit the amount of items my heap can hold. The problem is, when I try to access the top element, which should be the min, it gives me the max value. The code I have so far is pretty simple: class…
Felipe Ruiz
  • 181
  • 1
  • 6
0
votes
1 answer

Detach() and offsetUnset() difference in SPLObjecStorage

what is the diffrenece between Detach() and offsetUnset() in SPLObjecStorage. Looks like they do same thing. if so why there is two method for same job?
varuog
  • 3,031
  • 5
  • 28
  • 56
0
votes
2 answers

How to add an html element at each two items with foreach or SPL?

How can I interrupt a loop and adding an html element at each two iterations? Can a simple foreach do that or something in SPL? $item): ?>
  • $item->title
  • Run
    • 54,938
    • 169
    • 450
    • 748