本文整理汇总了PHP中CakeRequest::param方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeRequest::param方法的具体用法?PHP CakeRequest::param怎么用?PHP CakeRequest::param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeRequest
的用法示例。
在下文中一共展示了CakeRequest::param方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParamWriting
/**
* test writing request params with param()
*
* @return void
*/
public function testParamWriting()
{
$request = new CakeRequest('/');
$request->addParams(array('action' => 'index'));
$this->assertInstanceOf('CakeRequest', $request->param('some', 'thing'), 'Method has not returned $this');
$request->param('Post.null', null);
$this->assertNull($request->params['Post']['null']);
$request->param('Post.false', false);
$this->assertFalse($request->params['Post']['false']);
$request->param('Post.zero', 0);
$this->assertSame(0, $request->params['Post']['zero']);
$request->param('Post.empty', '');
$this->assertSame('', $request->params['Post']['empty']);
$this->assertSame('index', $request->action);
$request->param('action', 'edit');
$this->assertSame('edit', $request->action);
}
示例2: testReadingParams
/**
* Test using param()
*
* @return void
*/
public function testReadingParams()
{
$request = new CakeRequest();
$request->addParams(array('controller' => 'posts', 'admin' => true, 'truthy' => 1, 'zero' => '0'));
$this->assertFalse($request->param('not_set'));
$this->assertTrue($request->param('admin'));
$this->assertEquals(1, $request->param('truthy'));
$this->assertEquals('posts', $request->param('controller'));
$this->assertEquals('0', $request->param('zero'));
}