index.php
<?php
namespace app\index\controller;
use think\ Controller;
use think\ Db;
class Index extends Controller
{
public function index( $name)
{
echo "hello ". $name;
}
public function hello( $name){
$data= Db:: name( 'think_data')-> find();
$this-> assign( 'result', $data);
return $this-> fetch();
}
}
hello.html
< body >
{$result.id}--{$result.data}
</ body >
数据库
CREATE TABLE IF NOT EXISTS `think_data`(
`id` int(8) unsigned NOT NULL AUTO_INCREMENT,
`data` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
INSERT INTO `think_data`(`id`,`data`) VALUES
(1,'thinkphp'),
(2,'php'),
(3,'framework');
数据库配置 在 application/database.php中配置