PHP standard library (SPL)-SPL function ____ function

Source: Internet
Author: User


Array class_implements (mixed $class [, BOOL $autoload])-Returns all interfaces implemented by the specified class.

Array class_parents (mixed $class [, BOOL $autoload])-Returns the parent class of the specified class. int iterator_apply (traversable $iterator, callable $function [, array $args])-Invokes a user-defined function for each element in the iterator
int Iterator_count (traversable $iterator)-Calculates the number of elements in an iterator
Array Iterator_to_array (traversable $iterator [, bool $use = True])-copies elements from an iterator to an array

Example:

<?php 
    Interface foo{}
    class Bar implements foo{}
    class Bar2 extends bar{}
    
    //Return all interfaces
    implemented by the specified class Print_r (new Bar ()) (class_implements);
    
    Returns the parent class Print_r of the specified class
    (class_parents (new bar2));
    
    function _toupper (iterator $iterator) {
        echo strtoupper ($iterator-> current (). " \ n ");
        return TRUE;
    }
    $it = new Arrayiterator (Array ("A" => "Apples", "B" => "Bananas", "C" => "cherries"));
    Invokes a user-defined function for each element in the iterator
    iterator_apply ($it, "_toupper", Array ($it));
    
    Calculates the number of elements in the iterator
    $iterator _count = Iterator_count ($it);
    
    Copies the elements in the iterator to the array
    print_r (Iterator_to_array ($it, FALSE));
    
    Returns all available SPL class
    Print_r (Spl_classes ());


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.