PHP strcmp() ফাংশন
উদাহরণ
দুই স্ট্রিংকে তুলনা করুন (ক্ষতিগ্রস্ত হয়না):
<?php echo strcmp("Hello world!","Hello world!"); ?>
Definition and Usage
The strcmp() function compares two strings.
Comment:The strcmp() function is binary safe and case sensitive.
Tip:This function is similar to strncmp() The function is similar, but differently, by using strncmp() you can specify the number of characters used for comparison in each string.
Syntax
strcmp(string1,string2)
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare. |
string2 | Required. Specifies the second string to compare. |
Technical Details
Return value: |
This function returns:
|
PHP Version: | 4+ |
More Examples
Example 1
Compare two strings (case sensitive, Hello and hELLo output is different):
<?php echo strcmp("Hello","Hello"); echo "<br>"; echo strcmp("Hello","hELLo"); ?>
Example 2
Different return values:
<?php echo strcmp("Hello world!","Hello world!"); // Two strings are equal echo strcmp("Hello world!","Hello"); // string1 Greater than string2 echo strcmp("Hello world!","Hello world! Hello!"); // string1 Less than string2 ?>