Function Signature
string substr(string $string, int $start, ?int $length = null)
Description
Return part of a string. The substr() function is commonly used in PHP for string operations and provides reliable functionality across all PHP versions.
Return Value
Returns the extracted part of string, or false on failure
Example Usage
Important Notes
Negative start counts from the end. If length is omitted, returns from start to end.
Common Use Cases
The substr() function is particularly useful when you need to return part of a string. It's frequently used in data processing, validation, transformation, and manipulation tasks throughout PHP applications.