建立wish项目
把index.html->(wish-Index-Tpl-Index)
把css,images,js->(wish->Public)
把index.html里的./->!-PUBLIC-!/
如果模块不叫Index,你可以修改
$this->display(模板名);
模板文件的后缀名可以修改
'TMPL_TEMPLATE_SUFFIX'=>'.html'
建立wish数据库
用PathInfo方式访问网站
http://localhost:8888/wish/index.php/Index/index
有利于SEO优化
http://localhost:8888/wish/index.php/Index/index/uid/1
可以通过$_GET得到uid的值
介绍U函数
echo U('Index/index');die;
和'URL_HTML_SUFFIX'=>'',设置
/wish/index.php/Index/index
U函数可以带参数
echo U('Index/index',array('uid' =>1));die;
->/wish/index.php/Index/index/uid/1.html
echo U('Index/index',array('uid' =>1),'');die;//第三个参数为空,就不采用伪静态
->/wish/index.php/Index/index/uid/1.html
第四个参数用来决定是不是跳转去页面
U('show',array('uid' =>1),'','1');die;
讲一个3.1.3的新函数I
echo I('uid'); 自动从Get和Post里取出数据
p(I('get.'));
p(I('post.'));
U的第5个参数-显示域名
echo U('show',array('uid' =>1),'',0,true);die;
显示:
http://localhost:8888/wish/index.php/Index/show/uid/1
用U函数,方便程序修改,灵活布置
比如,如果 'URL_MODEL' => 0,
那么地址会变成:
http://localhost:8888/wish/index.php?m=Index&a=show&uid=1
'URL_MODEL' => 2,
->
http://localhost:8888/wish/Index/show/uid/1
现在开始修改模板:
Form:
<form action="{:U('handle')}" name='wish'>
表单提交先从常规的学起,然后学习异步的办法
<!-- <span id='send-btn'></span> -->
<input type="submit" />
然后讲了一个当时I的问题(在新的版本里已经没有了)
$this->_post('username'); //会用htmlspecialchars过滤
但是新的I里隐含的没有的。
在提交的里面写上
<sc
会弹出对话框(现在已经没有问题了)
当时的解决办法是:
echo I('username','','htmlspecailchars');
最佳答案