CI 묻고 답하기

제목 폴더에 있는 클래스 호출.
글쓴이 코드이그맨 작성시각 2016/06/17 10:13:21
댓글 : 6 추천 : 0 스크랩 : 0 조회수 : 17483   RSS

 

controllers

폴더에

 

 test라는 폴더를 생성하고, 

 

 

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class test extends CI_Controller {

   /**$this->load->model('');
    * Index Page for this controller.
    *
    * Maps to the following URL
    *        http://example.com/index.php/welcome
    * - or -
    *        http://example.com/index.php/welcome/index
    * - or -
    * Since this controller is set as the default controller in
    * config/routes.php, it's displayed at http://example.com/
    *
    * So any other public methods not prefixed with an underscore will
    * map to /index.php/welcome/<method_name>
    * @see https://codeigniter.com/user_guide/general/urls.html
    */
   public function index()
   {
      echo 'Look at this! test폴더에 있는 컨트롤러 호출';

   }


   public function session(){

      //PHP : session start
      session_start();

      //PHP : session save
      $_SESSION["key"] = "car_key";

      //PHP : session get
      echo $_SESSION["key"];

      echo "<br>";

      print_r($_SESSION);

      echo "<br>";

      echo session_id();

      echo "<br>";

      echo $_COOKIE["PHPSESSID"];

      // remove all session variables
   // session_unset();

      // destroy the session
   // session_destroy();


   }


}

 

위와 같은 test.php 파일을 생성하였습니다.

 

localhost/test/test

 

하면 잘 호출이 됩니당.

궁금한 점은!!

 

URI 라우팅 Routing을 보면서.

그럼 폴더를 끼고 부르는 클래스도 URL을 바꿀수 있을까?

그래서 한번 해보았습니다.

 

$route['test/test'] = 'zzzz';

 

요런식으로 했는데, 404 에러가 나오더군요 허허허

이런경우, 라우팅을 어떻게 처리를 해줘야하나요???

 

 

 다음글 페이징네이션 이쁘게 커스텀마이징 (3)
 이전글 다운그레이드는 어떻게 해야할까요?? (2)

댓글

한대승(불의회상) / 2016/06/17 10:47:00 / 추천 0
zzzz 클래스가 있나요?
코드이그맨 / 2016/06/17 10:47:50 / 추천 0

아뇨 없었습니다.

라우팅이라는게, 저걸 호출하면, 다른녀석을 호출하게끔 맵핑을 해주는 개념이었나요?

저는 문자열을 바꿔주는줄 ㄷㄷㄷㄷㄷ

한대승(불의회상) / 2016/06/17 10:49:54 / 추천 1
변수와 값을 바꾸면 zzzz 호출 했을때 test/test가 호출 됩니다.
코드이그맨 / 2016/06/17 10:53:44 / 추천 0
아직 정확히 이해는 못했지만, 답변 감사합니다!
샤오란 / 2016/06/17 11:32:32 / 추천 1

http://www.ciboard.co.kr/user_guide/kr/general/routing.html

메뉴얼보시면 아시겠지만,,, 혹시나 해서 그림첨부합니다. ㅎㅎ 더이상 설명할 방법이 없어요!.

정모 나오시면 알려드릴게요~

 

코드이그맨 / 2016/06/17 12:32:43 / 추천 0

헐 점심먹고 오니, 정성이 들어간 그림  설명 +_+..

감사합니다.

정모는..아직 초급개발자고, 급여를 받지못했으므로, 다음턴에 뵙도록 하겠습니다.