當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CakeRequest::isAjax方法代碼示例

本文整理匯總了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());
 }
開發者ID:xMyThoLoGyx,項目名稱:centremedicaletp3,代碼行數:27,代碼來源:CakeRequestTest.php


注:本文中的CakeRequest::isAjax方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。