LinkedNestBlog

Codeigniter Controller

by 이진원Dev
Controller


Ref.] 
  1. Controller : https://opentutorials.org/course/697/3829
  2. 컨트롤러란 무엇인가? : http://codeigniter-kr.org/user_guide_2.1.0/general/controllers.html
  3. index.php 없이 codeigniter 사용하려면 : http://www.codeigniter-kr.org/bbs/view/lecture?idx=7073

  • 설명  
    • URL과 상호작용하는 클래스 파일
  • 컨틀롤러 경로
    • /Applications/mampstack-5.6.20-0/apache2/htdocs/application/controllers 
  • 소스코드
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <?php
    defined('BASEPATH') OR exit('No direct script access allowed');
     
    //Controller : Url 을 mapping 하는 역할
    class Topic extends CI_Controller {
     
        // http://127.0.0.1:8080/index.php/topic
        public function index()
        {
            echo 'topic page';
        }
     
        // http://127.0.0.1:8080/index.php/topic/get/3
        // $id = 3
        public function get($id){
            echo "topic".$id;
        }
    }
     
    cs