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


PHP util::str_to_bool方法代碼示例

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


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

示例1: test_str_to_bool

 public function test_str_to_bool()
 {
     $this->assertTrue(util::str_to_bool('true'));
     $this->assertTrue(util::str_to_bool('yes'));
     $this->assertTrue(util::str_to_bool('y'));
     $this->assertFalse(util::str_to_bool('false'));
     $this->assertFalse(util::str_to_bool('no'));
     $this->assertFalse(util::str_to_bool('n'));
 }
開發者ID:rubymatrix,項目名稱:utilphp,代碼行數:9,代碼來源:util.php

示例2: getUri

 public function getUri($title, $id = 0, $contenttypeslug, $fulluri = true)
 {
     $contenttype = $this->getContentType($contenttypeslug);
     $tablename = $this->prefix . $contenttype['slug'];
     $id = intval($id);
     $fulluri = util::str_to_bool($fulluri);
     $slug = makeSlug($title);
     // don't allow strictly numeric slugs.
     if (is_numeric($slug)) {
         $slug = $contenttype['singular_slug'] . "-" . $slug;
     }
     // Only add 'entry/' if $full is requested.
     if ($fulluri) {
         $prefix = "/" . $contenttype['singular_slug'] . "/";
     }
     $query = "SELECT id from {$tablename} WHERE slug='{$slug}' and id!='{$id}';";
     $res = $this->db->query($query)->fetch();
     if (!$res) {
         $uri = $prefix . $slug;
     } else {
         for ($i = 1; $i <= 10; $i++) {
             $newslug = $slug . '-' . $i;
             $query = "SELECT id from {$tablename} WHERE slug='{$newslug}' and id!='{$id}';";
             $res = $this->db->query($query)->fetch();
             if (!$res) {
                 $uri = $prefix . $newslug;
                 break;
             }
         }
         // otherwise, just get a random slug.
         if (empty($uri)) {
             $slug = trimText($slug, 32, false, false) . "-" . makeKey(6);
             $uri = $prefix . $slug;
         }
     }
     return $uri;
 }
開發者ID:LeonB,項目名稱:site,代碼行數:37,代碼來源:storage.php

示例3: test_str_to_bool

 public function test_str_to_bool()
 {
     $this->assertTrue(util::str_to_bool('true'));
     $this->assertTrue(util::str_to_bool('yes'));
     $this->assertTrue(util::str_to_bool('y'));
     $this->assertTrue(util::str_to_bool('oui'));
     $this->assertTrue(util::str_to_bool('vrai'));
     $this->assertFalse(util::str_to_bool('false'));
     $this->assertFalse(util::str_to_bool('no'));
     $this->assertFalse(util::str_to_bool('n'));
     $this->assertFalse(util::str_to_bool('non'));
     $this->assertFalse(util::str_to_bool('faux'));
     $this->assertFalse(util::str_to_bool('test', false));
 }
開發者ID:vijay8090,項目名稱:pilot,代碼行數:14,代碼來源:UtilTest.php


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