PHP - Strncmp 函式



語法

int strncmp ( string $str1 , string $str2 , int $len )

定義和用法

它用於比較前 n 個字元。

返回值

它返回字串函式

引數

序號 引數及描述
1

string1

它指定要搜尋的第一個字串

2

string2

它指定要搜尋的第二個字串

3

length

它指定每個字串中用於比較的字元數

示例

嘗試以下示例

<?php
   echo strncmp("input","input",6);
   echo "<br>";
   
   echo strncmp("input","iMPut",6);
?>

這將產生以下結果:

0
8448
php_function_reference.htm
廣告