PHP

PHP Menu

PHP

substr_compare() Function - Definition, Syntax, Parameters, Examples

Definition

The substr_compare() function compares two strings from a specified start position.

Syntax

substr_compare(string1, string2, startpos, length, case)

Parameters

Parameter Description
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to compare.
startpos Required. Specifies where to start comparing in string1. If negative, it starts counting from the end of the string.
length Optional. Specifies how much of string1 to compare.
case Optional. A boolean value that specifies whether or not to perform a case-sensitive compare:
false - Default. Case-sensitive
true - Case-insensitive

Example

<?php
echo substr_compare("Welcome to PHP!", "hello php!", 3);

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods