CodeIgniter_02_Controller

My First Project

1.static page

1.1 URL Secret

http://example.com/[controller-class]/[controller-method]/[arguments]

Take it for example:domain name +project name, controller-class / controller-method / arguments.
=> https//localhost/CI4/welcome/login/1
part 1:domain name+project name
controller-class:welcome
controller-method:login
argument:1

2.MVC workflow

MVC architecture
There is mutual communciation between each two of these three components except from view and model.But more precisely the input from user is most provided via view instead of controller.To put it another way there are mutual communiciation between view and user.

3.Controller

3.1 definition

what does controller do?processing request and ask for data backwards to Model as well as forwarding data to View.

3.2 URL secret(V.2)

such as some private or privileged parts,we can put all the relevant functionalities into one specific folder.
CI4/Shop/check/parrmeter_1/…;
CI4/Mall/Shop/check/parameter_1/…;

3.3 Different folder Same name of php files

use … as …;

=>a hint behind this principle: codeigniter may track php file and inside method by namespace.


/app/controllers/mall/shop.php

<?php
namespace App\Controllers\mall;
use App\Controllers\BaseController;

class Shop extends BaseController
{
    public function index()
    {
        return view('shop');
    }
    public function product(){
        return view('product');
    }

    public function check($parameter , $parameter2){
        echo 'the parameter_01 is :' . $parameter . 'as well as the second parameter is '.$parameter2.';'; 
        //return view('check_'. $parameter);  
    }
    public function getInfo(){
        echo 'this is the protected method getInfo()';
    }
}


/app/controllers/shop.php

<?php

namespace App\Controllers;
use App\Controllers\mall\shop as MallShop;


class Shop extends BaseController
{
    public function index()
    {
        return view('shop');
    }
    public function product(){
        return view('product');
    }

    public function check($parameter , $parameter2){
        echo 'the parameter_01 is :' . $parameter . 'as well as the second parameter is '.$parameter2.';'; 
        echo '<br>';
        $mallshop = new MallShop();
        $mallshop->check($parameter,$parameter2);
        //return view('check_'. $parameter);  
    }
    public function getInfo(){
        echo 'this is the protected method getInfo()';
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值