本文整理汇总了PHP中CakeRequest::isAjax方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeRequest::isAjax方法的具体用法?PHP CakeRequest::isAjax怎么用?PHP CakeRequest::isAjax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeRequest
的用法示例。
在下文中一共展示了CakeRequest::isAjax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testisAjaxFlashAndFriends
/**
* Test ajax, flash and friends
*
* @return void
*/
public function testisAjaxFlashAndFriends()
{
$request = new CakeRequest('some/path');
$_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash';
$this->assertTrue($request->is('flash'));
$_SERVER['HTTP_USER_AGENT'] = 'Adobe Flash';
$this->assertTrue($request->is('flash'));
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->assertTrue($request->is('ajax'));
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHTTPREQUEST';
$this->assertFalse($request->is('ajax'));
$this->assertFalse($request->isAjax());
$_SERVER['HTTP_USER_AGENT'] = 'Android 2.0';
$this->assertTrue($request->is('mobile'));
$this->assertTrue($request->isMobile());
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 5.1; rv:2.0b6pre) Gecko/20100902 Firefox/4.0b6pre Fennec/2.0b1pre';
$this->assertTrue($request->is('mobile'));
$this->assertTrue($request->isMobile());
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; OMNIA7)';
$this->assertTrue($request->is('mobile'));
$this->assertTrue($request->isMobile());
}