In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to install spl standard library php", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how to install spl standard library php" this article bar.
php is not required to install spl standard library, because spl standard library is some of php built-in extension classes and extension interface, its content includes data structure, iterator, interface, exception, SPL function, file processing and other content, do not need additional configuration, can be used directly.
Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer
How to install SPL standard library?
PHP SPL Standard Library
1, Introduction
SPL, full name Standard PHP Library Chinese is a standard PHP library. PHP is built in some extension classes and extension interface, its content includes data structures, iterators, interfaces, exceptions, SPL functions, file processing and so on. SPL extensions are only available for PHP version 5.3 and later, and do not require additional configuration and can be used directly. Details can be found on PHP's official website https://www.php.net/spl. Here we mainly explain the use of data structure content in SPL.
2, using
1, stack
A stack is a first-in, first-out data structure. And can only operate on both ends of the stack, push or pull stack. The SplStack class provides the main functionality of a stack by using a doubly linked list. Think of popping as traversing an array of opposites
$stack = new SplStack();$stack->push ('Zhang San
');//push $stack->push ('Li Si
');$stack->unshift("Wang Wu");//put' Wang Wu 'at the bottom of the stack echo $stack->pop();//pop Li Si echo $stack->pop();//Zhang San echo $stack->pop();//Wang Wu
copy code
2. Pair
A queue is a first-in, first-out data structure. The SplQueue class also provides the main functionality of queues by using a doubly linked list.
$queue = new splQueue();$queue->enqueue(5);//enqueue $queue->enqueue(2);$queue->enqueue(1);$queue->enqueue(3);echo $queue->dequeue(); //dequeue 5echo $queue-> dequeue(); //2echo $queue->dequeue(); //1echo $queue-> dequeue (); //3
3. Stack
Heap is a data structure designed to implement priority queues, which is implemented by constructing binary heaps. The heap with the largest root node is called the maximum heap or the large root heap, the heap with the smallest root node is called the minimum heap or the small root heap, and the heap implemented by the maximum heap (SplMaxHeap) and the minimum heap (SplMinHeap) is inherited mainly for sorting.
//Max Heap output in ascending order $heap = new SplMaxHeap();$heap->insert ('E ');$heap->insert ('B');$heap->insert('D ');$heap->insert ('A');$heap->insert ('C ');echo $heap->extract(). '
'; # Eecho $heap->extract(). '
';# D//minheap descending output $heap = new SplMinHeap();$heap->insert ('E ');$heap->insert ('B');$heap-> insert('D ');$heap->insert ('A');$heap->insert ('C ');echo $heap->extract(). '
';echo $heap->extract(). '
';
Maximum heap: The element value of each parent node in the heap is greater than or equal to its child node (if any);
Minimum heap: the element value of each parent node in the heap is less than or equal to its child node (if any);
4. Fixed array
//Fixed array $i = 100000;$fixbtime = microtime(true);$fixstart = memory_get_usage();$fixArray = new SplFixedArray($i);//Generate fixed array of length i $fixend = memory_get_usage();$fixtime = microtime(true);//Regular array $btime2 = microtime (true);$arr = array_fill (0, $i, null);$end = memory_get_usage();//Time taken to generate fixed-length arrays and regular arrays echo $fixtime- $fixbtime, PHP_EOL; //fixed array 0.0065009593963623 echo microtime(true) - $btime2, PHP_EOL; //ordinary array 0.1734619140625 //generate memory occupied by fixed array and ordinary array of fixed length echo $fixend - $fixstart, PHP_EOL; //fixed array 4000280 byteecho $end - $fixend, PHP_EOL; //normal array 52194712 bytes
Fixed arrays consume significantly less memory and time than regular arrays. But for fixed arrays, the application for memory in one step, when the memory is not enough, it will report an error, when the memory is not used up, it will not be released, only waste. At the same time, fixed arrays are indexed arrays and cannot use keys other than integers.
The above is "php how to install spl standard library" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.