LoginSignup
1
0

More than 5 years have passed since last update.

【サルが書く】phpでのucfirst、lcfirstはどっちがどっちだかわからなくなる

Last updated at Posted at 2018-02-02

ucfirst関数、lcfirst関数

文字列(アルファベット、英字)の最初の文字を大文字及び小文字変換することができます。

引数
  $string
  最初の文字を大文字 / 小文字に変換する文字列を指定します。
返り値
  最初の文字を大文字 / 小文字に変換した文字列を返します。


// コードの例

<?php
// 文字列を指定する
$komoji = "banana is very cool.";
$oomoji = "BANANA IS VERY COOL.";

var_dump( ucfirst($komoji) );
var_dump( ucfirst($oomoji) );
var_dump( lcfirst($komoji) );
var_dump( lcfirst($oomoji) );

// 実行結果
string(20) "Banana is very cool."
string(20) "BANANA IS VERY COOL."
string(20) "banana is very cool."
string(20) "bANANA IS VERY COOL."

スネークケースとキャメルケースを使い分ける時に使えそうな気がする。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0