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


PHP Result::get方法代碼示例

本文整理匯總了PHP中Result::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Result::get方法的具體用法?PHP Result::get怎麽用?PHP Result::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Result的用法示例。


在下文中一共展示了Result::get方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_calendar

 public function get_calendar()
 {
     $date_start = date('Y-m-d', $_GET['start']);
     $date_end = date('Y-m-d', $_GET['end']);
     $variable = new Result();
     $variable->get();
     $day = 24 * 60 * 60 * 1000;
     foreach ($variable as $key => $value) {
         $title = null;
         $color = null;
         switch ($value->result_type_id) {
             case 1:
                 $title = "รายสัปดาห์";
                 $color = "#337AB7";
                 break;
             case 2:
                 $title = "รายเดือน";
                 $color = "#f0AD4E";
                 break;
             default:
                 $title = "รายวัน";
                 $color = "#5cb85c";
                 break;
         }
         $data_[] = array("title" => $value->title, "start" => date("Y-m-d", strtotime($value->import_time)), "url" => "reports/views/" . $value->id, "color" => $color);
     }
     echo json_encode(@$data_);
 }
開發者ID:ultraauchz,項目名稱:asean_cultural_mapping,代碼行數:28,代碼來源:reports.php

示例2: parse

 /**
  * Tries to parse a string and to get the domain name, tld and idn
  * converted domain name.
  *
  * If given string is not a domain name, it will add a default tld.
  *
  * Also skips given string if it is longer than 63 characters.
  *
  * @throws instance of AbstractException if throwExceptions = true
  * @param  string $unparsedString
  * @param  string $defaultTld
  * @return void
  */
 public function parse($unparsedString, $defaultTld = 'com')
 {
     try {
         if ($this->loaded === false) {
             $this->load();
         }
         $matchedDomain = '';
         $matchedDomainIdn = '';
         $matchedTld = '';
         $matchedTldIdn = '';
         $matchedGroup = '';
         $validHostname = true;
         $IdnaConverter = new Idna(array('idn_version' => 2008));
         preg_match('/^((http|https|ftp|ftps|news|ssh|sftp|gopher):[\\/]{2,})?([^\\/]+)/', mb_strtolower(trim($unparsedString), $this->encoding), $matches);
         $parsedString = $IdnaConverter->encode(end($matches));
         foreach ($this->tldList['content'] as $tldgroup => $tlds) {
             foreach ($tlds as $tld) {
                 if (preg_match('/\\.' . $tld . '$/', $parsedString, $trash)) {
                     $matchedTld = $tld;
                     $matchedTldIdn = $IdnaConverter->encode($tld);
                     $matchedDomain = substr($parsedString, 0, -strlen('.' . $matchedTld));
                     $matchedDomain = rtrim($matchedDomain, '.');
                     $matchedDomain = ltrim($matchedDomain, '.');
                     if ($matchedTld != 'name' && strpos($matchedDomain, '.')) {
                         $matchedDomain = str_replace('.', '', strrchr($matchedDomain, '.'));
                     }
                     if (strpos($matchedDomain, ' ')) {
                         $matchedDomain = explode(' ', $matchedDomain);
                         $matchedDomain = end($matchedDomain);
                     }
                     $matchedDomainIdn = $IdnaConverter->encode($matchedDomain);
                     $matchedGroup = $tldgroup;
                     break;
                 }
                 if ($tld == $parsedString) {
                     $matchedTld = $tld;
                     $matchedTldIdn = $IdnaConverter->encode($tld);
                     break;
                 }
             }
         }
         if ($matchedDomain == '' && strlen($matchedDomainIdn) <= 63 && $matchedTld == '') {
             $matchedDomain = $IdnaConverter->decode(preg_replace_callback('/[^a-zA-Z0-9\\-\\.]/', function ($match) use(&$validHostname) {
                 $validHostname = false;
             }, $IdnaConverter->encode($parsedString)));
             $matchedDomainIdn = $IdnaConverter->encode($matchedDomain);
             $matchedTld = $matchedTldIdn = $defaultTld;
         } elseif ($matchedDomain != '' && strlen($matchedDomainIdn) <= 63 && $matchedTld != '') {
             $matchedDomain = $IdnaConverter->decode(preg_replace_callback('/[^a-zA-Z0-9\\-\\.]/', function ($match) use(&$validHostname) {
                 $validHostname = false;
             }, $IdnaConverter->encode($matchedDomain)));
             $matchedDomainIdn = $IdnaConverter->encode($matchedDomain);
         } elseif ($matchedDomain == '' && $matchedTld != '') {
             $validHostname = false;
         } else {
             throw \Novutec\DomainParser\AbstractException::factory('UnparsableString', 'Unparsable domain name.');
         }
         $Result = new Result($matchedDomain, $matchedDomainIdn, $IdnaConverter->decode($matchedTld), $matchedTldIdn, $matchedGroup, $validHostname);
     } catch (\Novutec\DomainParser\AbstractException $e) {
         if ($this->throwExceptions) {
             throw $e;
         }
         $Result = new Result();
         $Result->error = $e->getMessage();
     }
     return $Result->get($this->format);
 }
開發者ID:JeffPedro,項目名稱:project-garage-sale,代碼行數:80,代碼來源:Parser.php


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