1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CodeIgniterで使えるディレクトリパス定数一覧

Last updated at Posted at 2021-04-08

#はじめに
CodeIgniterで開発を進める中で、パスを指定するときに迷わずに適切な定数を選べるようにするために、パス定数を一覧にしました。
記載されていないバリエーションがあれば、コメントで教えて頂ければ幸いです。

#PHPの定数

php
現在のパス                   //    /src/application/controllers/make/Make.php

basename(__FILE__);          //    Make.php
__FILE__ ;                   //    /src/application/controllers/make/Make.php
__DIR__ ;                    //    /src/application/controllers/make
dirname(__FILE__);           //    /src/application/controllers/make
$_SERVER['DOCUMENT_ROOT'];   //    /src/public/

#CodeIgniterの定数

php
現在のパス       // /src/application/controllers/make/Make.php

FCPATH;          // /src/public/
SELF;            // index.php
BASEPATH;        // /src/system/
APPPATH;         // /src/application/
VIEWPATH;        // /application/views/

#CodeIgniterのURLヘルパー

php
現在のパス                     // /src/application/controllers/make/Make.php

base_url('news/local/123');      //  http://example.com/index.php/news/local/123
site_url('news/local/123');      //  http://example.com/news/local/123
uri_string();                  // news/local/123
index_page();                  // 設定されているindexページ
1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?