Malhar Lathkar has Published 189 Answers

PHP Throwable interface

Malhar Lathkar
Published on 21-Sep-2020 11:52:46
IntroductionIn PHP 7, Throwable interface acts as base for any object that can be a parameter to throw statement, including Error and Exception. Both Error and Exception classes, from which predefined and user defined error and exception classes are derived respectively, implement Throwable interface. Following abstract methods are defined in ... Read More

PHP Serializable interface

Malhar Lathkar
Published on 21-Sep-2020 11:50:57
IntroductionThe Serializable interface is present in PHP library to build a class that provides custimised serialzing. PHP's serialize() function is able to serialize most of the values to a storable representation. However, objects of user defined classes can not be serialized. This interface makes it possible.SyntaxSerializable {    /* Methods ... Read More

PHP IteratorAggregate interface

Malhar Lathkar
Published on 21-Sep-2020 11:49:10
IntroductionIteratorAggregate interface extends abstract Traversable interface. It is implemented by a class to create external iterator. This interface introduces on abstract method called getIterator.SyntaxIteratorAggregate extends Traversable {    /* Methods */    abstract public getIterator ( void ) : Traversable }MethodsIteratorAggregate::getIterator — Retrieve an external iteratorThis function has no parameters and ... Read More

PHP Iterable interface

Malhar Lathkar
Published on 21-Sep-2020 11:46:53
IntroductionIterator interface extends abstract Traversable interface. PHP provides many built-in iterators (called SPL iterators) for many routine functionalities. Examples are ArrayIterator, DirectoryIterator etc. A user class that implements Iterator interface should implement abstract methods as defined in it.SyntaxIterator extends Traversable {    /* Methods */    abstract public current ( void ... Read More

PHP Generator class

Malhar Lathkar
Published on 21-Sep-2020 11:44:54
IntroductionTraversing a big collection of data using looping construct such as foreach would require large memory and considerable processing time. With generators it is possible to iterate over a set of data without these overheads. A generator function is similar to a normal function. However, instead of return statement in ... Read More

PHP Closure class

Malhar Lathkar
Published on 21-Sep-2020 11:42:45
IntroductionAnonymous functions (also called lambda) return object of Closure class. This class has some additional methods that provide further control over anonymous functions.SyntaxClosure {    /* Methods */    private __construct ( void )    public static bind ( Closure $closure , object $newthis [, mixed $newscope = "static" ] ... Read More

PHP ArrayAcccess interface

Malhar Lathkar
Published on 21-Sep-2020 11:40:52
IntroductionIn PHP, ArrayAccess interface is used to develop a class that provides array like access to one of properties which is an array. Such array property may be manipulated without exposing it during object creation. ArrayAccess interface defines following abstract methodsSyntaxArrayAccess {    /* Methods */    abstract public offsetExists ... Read More

PHP ArgumentCountError

Malhar Lathkar
Published on 21-Sep-2020 11:35:40
IntroductionPHP parser throws ArgumentCountError when arguments passed to a user defined function or method are less than those in its definition. ArgumentCountError class is inherited from TypeError classArgumentCountError ExampleIn Following example, a user defined function add() is defined to receive two arguments. However, if less than required number of arguments ... Read More

PHP ArithmeticError

Malhar Lathkar
Published on 21-Sep-2020 11:33:25
IntroductionArithmeticError class is inherited from Error class. This type of error may occurwhile performing certain mathemetical operations. One such scenario is attempt to perform bitwise shift operation by negative amount. This error is also thrown when call to intdiv() function results in value such that it is beyond legitimate boundaries of ... Read More

PHP AssertionError

Malhar Lathkar
Published on 21-Sep-2020 11:31:33
IntroductionAssertionError class is a subclass of Error class. This type of error is thrown when assert() returns FALSEassert() checks if given assertion is true or false, and throws AssertionError if it is false. The assert() function is defined as follows −Syntaxfor PHP 5 and PHP 7 assert ( mixed $assertion [, ... Read More
Advertisements