url方法 生成URL地址
helper.php 助手函数
echo Url::build(’/blog/read/id/5’).’
’;
echo url(‘blog/read’,‘id=5&name=thinkphp’)."
";
echo url(‘index/blog/read’,‘id=5&name=thinkphp’);
url生成的地址都是pathinfo模式。
json([‘name’=>‘thinkphp’,‘status’=>1]); 转换成json字符串
tp3:IS_GET,IS_POST
tp5:$request = Request::instance(); $request ->isGet(); isPost();
Controller声明周期:每次都是重新加载,并且new ,调用__construct,构造里面调用_initialize方法,然后调用操作方法,最后调用析构函数。
<?php class Person { static $id = 0; function __construct() { self::$id++; } static function getId() { return self::$id; } } echo Person::$id; //output 0 echo ""; $p1=new Person(); $p2=new Person(); $p3=new Person(); echo Person::$id; //output 3