<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 文件輔助函數 文件輔助函數文件包含了一些幫助你處理文件的函數。 [TOC=2,3] ## [加載輔助函數](http://codeigniter.org.cn/user_guide/helpers/file_helper.html#id4) 該輔助函數通過下面的代碼加載: ~~~ $this->load->helper('file'); ~~~ ## [可用函數](http://codeigniter.org.cn/user_guide/helpers/file_helper.html#id5) 該輔助函數有下列可用函數: read_file($file) 參數: * **$file**?(string) -- File path 返回: File contents or FALSE on failure 返回類型: string 返回指定文件的內容。 例如: ~~~ $string = read_file('./path/to/file.php'); ~~~ 可以是相對路徑或絕對路徑,如果失敗返回 FALSE 。 注解 路徑是相對于你網站的 index.php 文件的,而不是相對于控制器或視圖文件。 這是因為 CodeIgniter 使用的前端控制器,所以所有的路徑都是相對于 index.php 所在路徑。 注解 該函數已廢棄,使用 PHP 的原生函數?file_get_contents()?代替。 重要 如果你的服務器配置了?**open_basedir**?限制,該函數可能無法訪問限制之外的文件。 write_file($path,?$data[,?$mode = 'wb']) 參數: * **$path**?(string) -- File path * **$data**?(string) -- Data to write to file * **$mode**?(string) --?fopen()?mode 返回: TRUE if the write was successful, FALSE in case of an error 返回類型: bool 向指定文件中寫入數據,如果文件不存在,則創建該文件。 例如: ~~~ $data = 'Some file data'; if ( ! write_file('./path/to/file.php', $data)) { echo 'Unable to write the file'; } else { echo 'File written!'; } ~~~ 你還可以通過第三個參數設置寫模式: ~~~ write_file('./path/to/file.php', $data, 'r+'); ~~~ 默認的模式的 'wb' ,請閱讀?[PHP 用戶指南](http://php.net/manual/en/function.fopen.php)?了解寫模式的選項。 注解 路徑是相對于你網站的 index.php 文件的,而不是相對于控制器或視圖文件。 這是因為 CodeIgniter 使用的前端控制器,所以所有的路徑都是相對于 index.php 所在路徑。 注解 該函數在寫入文件時會申請一個排他性鎖。 delete_files($path[,?$del_dir = FALSE[,?$htdocs = FALSE]]) 參數: * **$path**?(string) -- Directory path * **$del_dir**?(bool) -- Whether to also delete directories * **$htdocs**?(bool) -- Whether to skip deleting .htaccess and index page files 返回: TRUE on success, FALSE in case of an error 返回類型: bool 刪除指定路徑下的所有文件。 例如: ~~~ delete_files('./path/to/directory/'); ~~~ 如果第二個參數設置為 TRUE ,那么指定路徑下的文件夾也一并刪除。 例如: ~~~ delete_files('./path/to/directory/', TRUE); ~~~ 注解 要被刪除的文件必須是當前系統用戶所有或者是當前用戶對之具有寫權限。 get_filenames($source_dir[,?$include_path = FALSE]) 參數: * **$source_dir**?(string) -- Directory path * **$include_path**?(bool) -- Whether to include the path as part of the filenames 返回: An array of file names 返回類型: array 獲取指定目錄下所有文件名組成的數組。如果需要完整路徑的文件名, 可以將第二個參數設置為 TRUE 。 例如: ~~~ $controllers = get_filenames(APPPATH.'controllers/'); ~~~ get_dir_file_info($source_dir,?$top_level_only) 參數: * **$source_dir**?(string) -- Directory path * **$top_level_only**?(bool) -- Whether to look only at the specified directory (excluding sub-directories) 返回: An array containing info on the supplied directory's contents 返回類型: array 獲取指定目錄下所有文件信息組成的數組,包括文件名、文件大小、日期 和 權限。 默認不包含子目錄下的文件信息,如有需要,可以設置第二個參數為 FALSE ,這可能會是一個耗時的操作。 例如: ~~~ $models_info = get_dir_file_info(APPPATH.'models/'); ~~~ get_file_info($file[,?$returned_values = array('name',?'server_path',?'size',?'date')]) 參數: * **$file**?(string) -- File path * **$returned_values**?(array) -- What type of info to return 返回: An array containing info on the specified file or FALSE on failure 返回類型: array 獲取指定文件的信息,包括文件名、路徑、文件大小,修改日期等。第二個參數可以用于 聲明只返回回你想要的信息。 第二個參數?$returned_values?有效的值有:name、size、date、readable、writeable、?executable?和?fileperms?。 get_mime_by_extension($filename) 參數: * **$filename**?(string) -- File name 返回: MIME type string or FALSE on failure 返回類型: string 根據?config/mimes.php?文件中的配置將文件擴展名轉換為 MIME 類型。 如果無法判斷 MIME 類型或 MIME 配置文件讀取失敗,則返回 FALSE 。 ~~~ $file = 'somefile.png'; echo $file.' is has a mime type of '.get_mime_by_extension($file); ~~~ 注解 這個函數只是一種簡便的判斷 MIME 類型的方法,并不準確,所以 請不要用于安全相關的地方。 symbolic_permissions($perms) 參數: * **$perms**?(int) -- Permissions 返回: Symbolic permissions string 返回類型: string 將文件權限的數字格式(譬如?fileperms()?函數的返回值)轉換為標準的符號格式。 ~~~ echo symbolic_permissions(fileperms('./index.php')); // -rw-r--r-- ~~~ octal_permissions($perms) 參數: * **$perms**?(int) -- Permissions 返回: Octal permissions string 返回類型: string 將文件權限的數字格式(譬如?fileperms()?函數的返回值)轉換為三個字符的八進制表示格式。 ~~~ echo octal_permissions(fileperms('./index.php')); // 644 ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看