PHP Articles

Page 31 of 81

PHP ArrayAcccess interface

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 366 Views

In PHP, the ArrayAccess interface allows objects to be accessed like arrays using square bracket notation. When a class implements this interface, you can use $obj['key'] syntax to interact with the object's internal data without exposing the underlying array property directly. Syntax ArrayAccess { /* Methods */ abstract public offsetExists ( mixed $offset ) : bool abstract public offsetGet ( mixed $offset ) : mixed abstract public offsetSet ( mixed $offset , mixed $value ) : void ...

Read More

PHP ArgumentCountError

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 595 Views

PHP throws ArgumentCountError when a function or method is called with fewer arguments than required in its definition. The ArgumentCountError class inherits from TypeError and can be caught using try-catch blocks. Basic Function Example Here's an example where a user-defined function add() expects two arguments but receives only one ? Too few arguments to function add(), 1 passed and exactly 2 expected Class Method Example ArgumentCountError also occurs with class methods when insufficient arguments are provided ? Too few arguments to function MyClass::setData(), ...

Read More

PHP ArithmeticError

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 335 Views

The ArithmeticError class is inherited from the Error class. This type of error occurs while performing certain mathematical operations. One such scenario is attempting to perform a bitwise shift operation by a negative amount. This error is also thrown when a call to the intdiv() function results in a value that is beyond the legitimate boundaries of an integer. Bitwise Shift with Negative Number In the following example, an attempt is made to use the binary shift operator with a negative operand. This results in an ArithmeticError ? Bit shift by negative ...

Read More

PHP AssertionError

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 360 Views

The AssertionError class is a subclass of the Error class in PHP. This exception is thrown when the assert() function evaluates to FALSE. The assert() function checks if a given assertion is true and throws an AssertionError if the condition fails. Syntax // PHP 5 and PHP 7 assert ( mixed $assertion [, string $description ] ) : bool // PHP 7 only assert ( mixed $assertion [, Throwable $exception ] ) : bool Parameters Parameter Description assertion String or boolean expression to evaluate description Failure message ...

Read More

PHP CompileError

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 286 Views

In PHP 7.3 onwards, CompileError exception has been added. This class inherits the Error class. Some error conditions that previously resulted in fatal errors now throw a CompileError. This affects compilation errors that are likely to be thrown by the token_get_all() function when parsing invalid PHP syntax. The token_get_all() function uses Zend lexical scanner to parse a given string into PHP language tokens. When used in TOKEN_PARSE mode, it can throw a CompileError for invalid PHP code. Syntax token_get_all ( string $source [, int $flags = 0 ] ) : array Parameters ...

Read More

PHP DivisionByZeroError

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 2K+ Views

The DivisionByZeroError class is a subclass of ArithmeticError class. This type of error occurs when division operations involve a denominator value of zero. This can also occur when a modulo operator (%) has 0 as the second operand, and the intdiv() function has 0 as its second argument. Modulo Division by Zero The modulo operator (%) throws a DivisionByZeroError when the divisor is zero ? Modulo by zero Integer Division by Zero The intdiv() function also raises DivisionByZeroError when the divisor is zero ? ...

Read More

PHP ParseError

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 402 Views

ParseError class extends CompileError class and is thrown when PHP code inside a string passed to the eval() function contains syntax errors. The eval() function evaluates a given string as PHP code. If the code contains syntax errors, it throws a ParseError instead of causing a fatal error. Syntax eval ( string $code ) : mixed Parameters Parameter Description code Valid PHP code to be evaluated. Must not include opening/closing PHP tags and must end with semicolon. Valid code returns NULL, while syntax errors in the ...

Read More

PHP Types of Errors

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 471 Views

PHP's internal Error types are represented by classes that are inherited from Error class. The Error class implements Throwable interface and provides a structured way to handle different types of runtime errors. Error Class Properties message − The error message code − The error code file − The filename where the error happened line − The line where the error happened Error Class Methods __construct() − Construct the error object getMessage() − Gets the error ...

Read More

PHP Zip context options

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 288 Views

PHP's ZIP extension provides the zip:// stream wrapper for reading files from ZIP archives. Starting from PHP 7.2.0, it supports passwords for encrypted archives through context options. Zip Context Options The ZIP wrapper supports only one context option − Option Type Description password string Password for encrypted ZIP archives Example Note: This example requires file system access to create and read ZIP files. First, create a password-protected ZIP archive − Now, read the file from the encrypted ZIP archive using context ...

Read More

PHP SSL context options

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 2K+ Views

SSL context options in PHP allow you to configure secure connections when using ssl:// and tls:// transports. These options control certificate verification, encryption settings, and connection security for secure network communications. SSL Context Options The following table lists all available SSL context options and their purposes ? Option Description peer_name Peer name to be used. If this value is not set, then the name is guessed based on the hostname used when opening the stream. verify_peer Require verification of SSL certificate used. Defaults to TRUE. verify_peer_name Require verification of ...

Read More
Showing 301–310 of 802 articles
« Prev 1 29 30 31 32 33 81 Next »
Advertisements