PHP

PHP Menu

PHP

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

Definition

The strncmp() function compares(binary-safe and case-sensitive) two strings.

Syntax

strncmp(string1, string2, length)

Parameters

Parameter Description
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to compare.
length Required. Specify the number of characters from each string to be used in the comparison.

Example

<?php
echo strncmp("Welcome to PHP!", "welcome to Php!", 4);

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods