• Email
  • Favorite
  • Download
  • Embed
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

SPL, not a bridge too far

by Michelangelo van Dam on Jun 12, 2009

  • 4,553 views

With this presentation I hope to show that using SPL doesn't require a PHD and that it really benefits your application design, maintainability and implements best practices to solve common development...

With this presentation I hope to show that using SPL doesn't require a PHD and that it really benefits your application design, maintainability and implements best practices to solve common development problems.

Accessibility

Categories

Tags

dpc09 php spl dpc iterator webdev

More...

Upload Details

Uploaded via SlideShare as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel

1 Embed 10

http://www.slideshare.net 10

Statistics

Favorites
5
Downloads
94
Comments
1
Embed Views
10
Views on SlideShare
4,543
Total Views
4,553

11 of 1 previous next

  • guestc4db8b guestc4db8b Am I missing something, or have you completely missed the point with much of SPL?
    ArrayObject is pretty much what it says it is. It acts just like an array, but is an object.

    <?php

    $myArray = array(
    'monkey' => 'bananas',
    'rabbit' => 'carrots',
    'ogre' => 'onions' );

    $arrayObj = new ArrayObject($myArray);
    echo count($arrayObj) . '\n'; // 3 because it implements Countable
    echo 'Ogres exist ? ' . (array_key_exists('ogre', $arrayObj) ? 'Yes' : 'No') . '\n';
    //or
    echo 'Ogres exist ? ' . (isset($arrayObj['ogre']) ? 'Yes' : 'No') . '\n'; echo 'Ogres eat ' . $arrayObj['ogre'] . '\n';

    $arrayObj->ksort();
    //getIterator() gets called implicitly
    foreach($arrayObj as $key => $value){
    echo $key . ' eats ' . $value . '\n';
    }
    ?>
    outputs:
    Ogres exist ? Yes
    Ogres exist ? Yes
    Ogres eat onions
    monkey eats bananas
    ogre eats onions
    rabbit eats carrots

    You're right though in regards to documentation. It's seriously lacking, and therefore most of the examples found online don't show what SPL actually does.
    2 years ago Reply
    Are you sure you want to Yes No
Post Comment
Edit your comment Cancel

SPL, not a bridge too far — Presentation Transcript