本文整理匯總了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());
}