Hướng dẫn substr_compare in php
❮ PHP String Reference Show ExampleCompare two strings: echo substr_compare("Hello world","Hello world",0); Try it Yourself » Definition and UsageThe substr_compare() function compares two strings from a specified start position. Tip: This function is binary-safe and optionally case-sensitive. Syntaxsubstr_compare(string1,string2,startpos,length,case) Parameter Values
Technical Details
More ExamplesExampleCompare two strings, when start position in string1 for the comparison is 6th: echo substr_compare("Hello world","world",6); Try it Yourself » ExampleUsing all parameters: echo substr_compare("world","or",1,2); Try it Yourself » ExampleDifferent return values: echo substr_compare("Hello world!","Hello world!",0); // the
two strings are equal Try it Yourself » ❮ PHP String Reference ❮ Tham chiếu chuỗi PHP Thí dụSo sánh hai chuỗi: echo substr_compare("Hello world","Hello world",0); Định nghĩa và Cách sử dụngHàm substr_compare () so sánh hai chuỗi từ một vị trí bắt đầu được chỉ định. Mẹo: Hàm này an toàn nhị phân và có phân biệt chữ hoa chữ thường. Cú phápsubstr_compare(string1,string2,startpos,length,case) Giá trị tham số
Chi tiết kỹ thuật
Các ví dụ khácThí dụSo sánh hai chuỗi, khi vị trí bắt đầu trong chuỗi1 để so sánh là thứ 6: echo substr_compare("Hello world","world",6); Thí dụSử dụng tất cả các tham số: echo substr_compare("world","or",1,2); Thí dụCác giá trị trả về khác nhau: echo substr_compare("Hello world!","Hello world!",0); // the two strings are equal ❮ Tham chiếu chuỗi PHP |