facebook twitter hatena line email

Php/cakephp/helloworld

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

コントローラーのみでhelloworld

controllers/pages_controller.php

<?php
class PagesController extends AppController {
 
    public $name = "Pages";
    public $uses = null;
    public $autoRender = false;
 
    function display() {
        echo "Hello World!";
    }
}

ビューを使ったhelloworld

controllers/pages_controller.php

<?php
class PagesController extends AppController {
 
    public $name = "Pages";
    public $uses = null;
    public $autoRender = false;
 
    function display() {
        $this->set("content", "Hello World!");
        $this->render('/pages/display');
    }
}

views/pages/display.ctp

<?php echo $content; ?>