本文整理汇总了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_);
}
示例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);
}