update page now

Voting

: max(five, one)?
(Example: nine)

The Note You're Voting On

svenr at selfhtml dot org
14 years ago
Best method:

<?php

if ($object instanceof SeekableIterator) {
  echo "\$object has method seek()";
}

?>

Please, make use of checking if a particular interface has been implemented to assure that the object you are dealing with definately has the methods you are about to use.

This also works as typehinting:

<?php

class foo {
  public function doSomeSeeking(SeekableIterator $seekMe) {
    $seekMe->seek(10); // will work, otherwise Typehint triggers complaints
  }
}

?>

<< Back to user notes page

To Top