PHP/英文字の大文字小文字を区別せずに比較する関数・strcasecmp
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* PHPで英文字の大文字小文字を区別せずに比較する関数・strc...
PHPのstrcasecmp関数を使うと英字の大文字、小文字を区別せず...
以下にサンプルスクリプト等を紹介します。
#contents
#htmlinsertpcsp(web-top.html,web-sp.html)
* strcasecmpのサンプルスクリプト [#g4edd78e]
strcasecmpの仕様は以下のリンクを確認してみてください。~
http://jp1.php.net/manual/ja/function.strcasecmp.php
#ref(strcasecmp.zip)
<?php
$a = "hello world";
$b = "HELLO WORLD";
if (strcmp($a, $b) != 0) {
print("strcmp($a, $b) : not equal.\n");
}
if (strcasecmp($a, $b) == 0) {
print("strcasecmp($a, $b) : equal.\n");
}
?>
strcmpとstrcasecmpの比較のためにstrcmpとstrcasecmpの2つ...
strcmp, strcasecmpともに内容が同一の場合は0が返却されます。
** strcasecmpサンプルスクリプトの実行結果 [#f28fc0b8]
下記の出力の通り、英字の大文字小文字を区別せず比較できて...
$ php strcasecmp.php
strcmp(hello world, HELLO WORLD) : not equal.
strcasecmp(hello world, HELLO WORLD) : equal.
以上、strcasecmpのPHPサンプルスクリプトでした。
#htmlinsertpcsp(web-btm.html,web-sp.html)
終了行:
#navi(../)
* PHPで英文字の大文字小文字を区別せずに比較する関数・strc...
PHPのstrcasecmp関数を使うと英字の大文字、小文字を区別せず...
以下にサンプルスクリプト等を紹介します。
#contents
#htmlinsertpcsp(web-top.html,web-sp.html)
* strcasecmpのサンプルスクリプト [#g4edd78e]
strcasecmpの仕様は以下のリンクを確認してみてください。~
http://jp1.php.net/manual/ja/function.strcasecmp.php
#ref(strcasecmp.zip)
<?php
$a = "hello world";
$b = "HELLO WORLD";
if (strcmp($a, $b) != 0) {
print("strcmp($a, $b) : not equal.\n");
}
if (strcasecmp($a, $b) == 0) {
print("strcasecmp($a, $b) : equal.\n");
}
?>
strcmpとstrcasecmpの比較のためにstrcmpとstrcasecmpの2つ...
strcmp, strcasecmpともに内容が同一の場合は0が返却されます。
** strcasecmpサンプルスクリプトの実行結果 [#f28fc0b8]
下記の出力の通り、英字の大文字小文字を区別せず比較できて...
$ php strcasecmp.php
strcmp(hello world, HELLO WORLD) : not equal.
strcasecmp(hello world, HELLO WORLD) : equal.
以上、strcasecmpのPHPサンプルスクリプトでした。
#htmlinsertpcsp(web-btm.html,web-sp.html)
ページ名: