rename( str1, str2 )
戻り値(bool) |
ファイル名の変更に成功した場合:TRUE ファイル名の変更に失敗した場合:FALSE |
引数1(str1) | 変更前のファイル名(ディレクトリ名) |
引数2(int2) | 変更後のファイル名(ディレクトリ名) |
<?php //「test.txt」という名前の空のファイルを作成する。 touch( "test.txt" ); if( !file_exists( "hoge.txt" ) ){ //ファイル名「test.txt」を「hoge.txt」に変更する。 rename( "test.txt", "hoge.txt" ); }else{ print "hoge.txt はすでに存在しています。"; } //「test_dir」 という名前のディレクトリ(フォルダ)を作成する。 mkdir( "test_dir" ); if( !file_exists( "hoge_dir" ) ){ //ディレクトリ名「test_dir」を「hoge_dir」に変更する。 rename( "test_dir", "hoge_dir" ); }else{ print "hoge_dir はすでに存在しています。"; } ?>
スポンサーリンク
このサイトはリンクフリーです。リンクを貼る際に連絡は不要です。
© since 2005 PHP Webリファレンス all rights reserved.