当前位置: 首页>>代码示例>>PHP>>正文


PHP boolval函数代码示例

本文整理汇总了PHP中boolval函数的典型用法代码示例。如果您正苦于以下问题:PHP boolval函数的具体用法?PHP boolval怎么用?PHP boolval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了boolval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAll

 /**
  * Get all options
  *
  * @param bool $force Force
  * @return array|mixed
  */
 public static function getAll($force = false)
 {
     if ($force === true || self::$_config['cache'] === false || self::$_config['cache'] === true && !Cache::read(self::$_config['cache_name'])) {
         $options = self::$_table->find('all');
         $optionsArray = [];
         foreach ($options as $v) {
             $value = $v->{self::$_config['column_value']};
             $setting = Settings::getSetting($v->{self::$_config['column_key']});
             if (!is_null($setting)) {
                 switch ($setting['type']) {
                     case 'boolean':
                         $value = boolval($value);
                         break;
                     case 'integer':
                         $value = intval($value);
                         break;
                     case 'float':
                         $value = floatval($value);
                         break;
                 }
             }
             $optionsArray[$v->{self::$_config['column_key']}] = $value;
         }
         if (self::$_config['cache'] === true) {
             Cache::write(self::$_config['cache_name'], $optionsArray, self::$_config['cache_config']);
         }
         return $optionsArray;
     }
     return Cache::read(self::$_config['cache_name']);
 }
开发者ID:ThreeCMS,项目名称:ThreeCMS,代码行数:36,代码来源:SettingsData.php

示例2: hasLabel

 /**
  * @param $key
  * @param $value
  * @return bool
  */
 public function hasLabel($key, $value = null)
 {
     if (!$value) {
         return (bool) isset($this->labels[$key]);
     }
     return boolval((isset($this->labels[$key]) ? $this->labels[$key] : false) === $value);
 }
开发者ID:domraider,项目名称:rxnet,代码行数:12,代码来源:EventTrait.php

示例3: __construct

 public function __construct($boolean)
 {
     if (!is_bool($boolean)) {
         $boolean = boolval($boolean);
     }
     $this->boolean = $boolean;
 }
开发者ID:1455931078,项目名称:web-server-source,代码行数:7,代码来源:BooleanLiteral.php

示例4: renderJson

 /**
  *    输出Json数据
  */
 public function renderJson($result, $msg, $data = [])
 {
     $arr = ['result' => boolval($result), 'message' => $msg, 'data' => $data];
     $res = Yii::$app->response;
     $res->format = $res::FORMAT_JSON;
     return $arr;
 }
开发者ID:dawei101,项目名称:plants,代码行数:10,代码来源:Controller.php

示例5: run

 /**
  * @return string
  */
 public function run()
 {
     parent::run();
     if (null === $this->rootCategory) {
         return '';
     }
     $cacheKey = $this->className() . ':' . implode('_', [$this->viewFile, $this->rootCategory, null === $this->depth ? 'null' : intval($this->depth), intval($this->includeRoot), intval($this->fetchModels), intval($this->onlyNonEmpty), implode(',', $this->excludedCategories), \Yii::$app->request->url]) . ':' . json_encode($this->additional);
     if (false !== ($cache = \Yii::$app->cache->get($cacheKey))) {
         return $cache;
     }
     /** @var array|Category[] $tree */
     $tree = Category::getMenuItems(intval($this->rootCategory), $this->depth, boolval($this->fetchModels));
     if (true === $this->includeRoot) {
         if (null !== ($_root = Category::findById(intval($this->rootCategory)))) {
             $tree = [['label' => $_root->name, 'url' => Url::toRoute(['@category', 'category_group_id' => $_root->category_group_id, 'last_category_id' => $_root->id]), 'id' => $_root->id, 'model' => $this->fetchModels ? $_root : null, 'items' => $tree]];
         }
     }
     if (true === $this->onlyNonEmpty) {
         $_sq1 = (new Query())->select('main_category_id')->distinct()->from(Product::tableName());
         $_sq2 = (new Query())->select('category_id')->distinct()->from('{{%product_category}}');
         $_query = (new Query())->select('id')->from(Category::tableName())->andWhere(['not in', 'id', $_sq1])->andWhere(['not in', 'id', $_sq2])->all();
         $this->excludedCategories = array_merge($this->excludedCategories, array_column($_query, 'id'));
     }
     $tree = $this->filterTree($tree);
     $cache = $this->render($this->viewFile, ['tree' => $tree, 'fetchModels' => $this->fetchModels, 'additional' => $this->additional, 'activeClass' => $this->activeClass, 'activateParents' => $this->activateParents]);
     \Yii::$app->cache->set($cacheKey, $cache, 0, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Category::className()), ActiveRecordHelper::getCommonTag(Product::className())]]));
     return $cache;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:31,代码来源:CategoriesList.php

示例6: tril

/**
 * @param $value
 *
 * @return bool|null
 */
function tril($value)
{
    if (null === $value || false === $value || true === $value) {
        return $value;
    }
    if (is_array($value)) {
        return !empty($value);
    }
    if (is_object($value)) {
        return true;
    }
    if (is_double($value) && is_nan($value)) {
        return null;
    }
    $value = trim(strtolower($value));
    if (in_array($value, ['', 'null', 'maybe'])) {
        return null;
    }
    if (in_array($value, ['no', 'off', '0', 'false'])) {
        return false;
    }
    if (in_array($value, ['yes', 'on', '1', 'true'])) {
        return true;
    }
    return boolval($value);
}
开发者ID:azder,项目名称:fun-php,代码行数:31,代码来源:fun.php

示例7: wpas_core_settings_general

/**
 * Add plugin core settings.
 *
 * @param  array $def Array of existing settings
 *
 * @return array      Updated settings
 */
function wpas_core_settings_general($def)
{
    $user_registration = boolval(get_option('users_can_register'));
    $registration_lbl = true === $user_registration ? _x('allowed', 'User registration is allowed', 'awesome-support') : _x('not allowed', 'User registration is not allowed', 'awesome-support');
    $settings = array('general' => array('name' => __('General', 'awesome-support'), 'options' => array(array('name' => __('Misc', 'awesome-support'), 'type' => 'heading'), array('name' => __('Default Assignee', 'awesome-support'), 'id' => 'assignee_default', 'type' => 'select', 'desc' => __('Who to assign tickets to in the case that auto-assignment wouldn&#039;t work. This does NOT mean that all tickets will be assigned to this user. This is a fallback option. To enable/disable auto assignment for an agent, please do so in the user profile settings.', 'awesome-support'), 'options' => isset($_GET['post_type']) && 'ticket' === $_GET['post_type'] && isset($_GET['page']) && 'wpas-settings' === $_GET['page'] ? wpas_list_users('edit_ticket') : array(), 'default' => ''), array('name' => __('Allow Registrations', 'awesome-support'), 'id' => 'allow_registrations', 'type' => 'radio', 'desc' => sprintf(__('Allow users to register on the support page. This setting can be enabled even though the WordPress setting is disabled. Currently, registrations are %s by WordPress.', 'awesome-support'), "<strong>{$registration_lbl}</strong>"), 'default' => 'allow', 'options' => array('allow' => __('Allow registrations', 'awesome-support'), 'disallow' => __('Disallow registrations', 'awesome-support'), 'disallow_silent' => __('Disallow registrations without notice (just show the login form)', 'awesome-support'))), array('name' => __('Replies Order', 'awesome-support'), 'id' => 'replies_order', 'type' => 'radio', 'desc' => __('In which order should the replies be displayed (for both client and admin side)?', 'awesome-support'), 'options' => array('ASC' => __('Old to New', 'awesome-support'), 'DESC' => __('New to Old', 'awesome-support')), 'default' => 'ASC'), array('name' => __('Replies Per Page', 'awesome-support'), 'id' => 'replies_per_page', 'type' => 'text', 'default' => 10, 'desc' => __('How many replies should be displayed per page on a ticket details screen?', 'awesome-support')), array('name' => __('Hide Closed', 'awesome-support'), 'id' => 'hide_closed', 'type' => 'checkbox', 'desc' => __('Only show open tickets when clicking the "All Tickets" link.', 'awesome-support'), 'default' => true), array('name' => __('Show Count', 'awesome-support'), 'id' => 'show_count', 'type' => 'checkbox', 'desc' => __('Display the number of open tickets in the admin menu.', 'awesome-support'), 'default' => true), array('name' => __('Old Tickets', 'awesome-support'), 'id' => 'old_ticket', 'type' => 'text', 'default' => 10, 'desc' => __('After how many days should a ticket be considered &laquo;old&raquo;?', 'awesome-support')), array('name' => __('Departments', 'awesome-support'), 'id' => 'departments', 'type' => 'checkbox', 'desc' => __('Enable departments management.', 'awesome-support'), 'default' => false), array('name' => __('Products Management', 'awesome-support'), 'type' => 'heading', 'options' => wpas_get_products_options()), array('name' => __('Plugin Pages', 'awesome-support'), 'type' => 'heading'), array('name' => __('Ticket Submission', 'awesome-support'), 'id' => 'ticket_submit', 'type' => 'select', 'multiple' => true, 'desc' => sprintf(__('The page used for ticket submission. This page should contain the shortcode %s', 'awesome-support'), '<code>[ticket-submit]</code>'), 'options' => wpas_list_pages(), 'default' => ''), array('name' => __('Tickets List', 'awesome-support'), 'id' => 'ticket_list', 'type' => 'select', 'multiple' => false, 'desc' => sprintf(__('The page that will list all tickets for a client. This page should contain the shortcode %s', 'awesome-support'), '<code>[tickets]</code>'), 'options' => wpas_list_pages(), 'default' => ''), array('name' => __('Terms & Conditions', 'awesome-support'), 'type' => 'heading'), array('name' => __('Content', 'awesome-support'), 'id' => 'terms_conditions', 'type' => 'editor', 'default' => '', 'desc' => __('Terms & conditions are not mandatory. If you add terms, a mandatory checkbox will be added in the registration form. Users won\'t be able to register if they don\'t accept your terms', 'awesome-support'), 'settings' => array('quicktags' => true, 'textarea_rows' => 7)), array('name' => __('Credit', 'awesome-support'), 'type' => 'heading'), array('name' => __('Show Credit', 'awesome-support'), 'id' => 'credit_link', 'type' => 'checkbox', 'desc' => __('Do you like this plugin? Please help us spread the word by displaying a credit link at the bottom of your ticket submission page.', 'awesome-support'), 'default' => false))));
    return array_merge($def, $settings);
}
开发者ID:alpha1,项目名称:Awesome-Support,代码行数:14,代码来源:settings-general.php

示例8: rememberLogin

 public static function rememberLogin($value)
 {
     if (boolval($value)) {
         //die(Session::get('user'));
         setcookie('absotus_user', json_encode(Session::get('user')), time() + 86400 * 30, '/Absotus');
     }
 }
开发者ID:andrebonner,项目名称:Absotus,代码行数:7,代码来源:Auth.php

示例9: find

 /**
  * Case-insensitive search in directory contents
  * @param string|IStringBehaviour $needle
  * @param bool|false $isNeedleRegex
  * @param bool|false $firstMatchOnly
  * @return array
  * @throws NotReadableException
  */
 public function find($needle, $isNeedleRegex = false, $firstMatchOnly = false)
 {
     $matches = [];
     try {
         $contents = $this->toArray();
     } catch (NotReadableException $e) {
         throw $e;
     }
     foreach ($contents as $entry) {
         if ($isNeedleRegex && boolval(preg_match($needle, $entry))) {
             if ($firstMatchOnly) {
                 return $entry;
             } else {
                 $matches[] = $entry;
             }
         } elseif (!$isNeedleRegex && stripos($entry, $needle) !== false) {
             if ($firstMatchOnly) {
                 return $entry;
             } else {
                 $matches[] = $entry;
             }
         }
     }
     return $matches;
 }
开发者ID:corgi-php,项目名称:corgi-file,代码行数:33,代码来源:DirectoryContents.php

示例10: bool

 public function bool($id, $default = null)
 {
     if (NULL !== ($val = $this->read($id))) {
         return boolval($val);
     }
     return $default;
 }
开发者ID:niclaslindberg,项目名称:webx-db,代码行数:7,代码来源:DefaultRowWrapper.php

示例11: config

 /**
  * @inheritdoc
  */
 public function config($config)
 {
     $def_conf = ['root_path' => realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', '..'])), 'mapper_path' => '', 'log_dir' => __DIR__, 'debug' => false, 'connections' => []];
     $conf = array_merge($def_conf, $config);
     $root_path = $conf['root_path'];
     $map_path = $conf['mapper_path'];
     $log_dir = $conf['log_dir'];
     $debug = boolval($conf['debug']);
     foreach ($conf['connections'] as $connection) {
         $name = $connection['name'];
         $cls = $connection['class'];
         $connection['debug'] = $debug;
         if (!isset($connection['root_path'])) {
             $connection['root_path'] = $root_path;
         }
         if (!isset($connection['mapper_path'])) {
             $connection['mapper_path'] = $map_path;
         }
         if (isset($connection['logger'])) {
             if (!isset($connection['logger']['log_dir'])) {
                 $connection['logger']['log_dir'] = $log_dir;
             }
         }
         $this->configs[$name] = $connection;
         $this->connections[$name] = new \ReflectionClass($cls);
     }
     return $this;
 }
开发者ID:wwtg99,项目名称:data_pool,代码行数:31,代码来源:DefaultDataPool.php

示例12: listOfPassedTests

 public function listOfPassedTests(User $user, $data) : Query
 {
     switch ($data['answer_type']) {
         case 'all':
             $answer_type = null;
             break;
         case 0:
         case 1:
             $answer_type = $data['answer_type'];
             break;
     }
     empty($data['start']) ? $start = date('Y-m-d') : ($start = $data['start']);
     empty($data['end']) ? $end = date('Y-m-d') : ($end = $data['end']);
     $queryBuilder = $this->getEntityManager()->createQueryBuilder();
     $queryBuilder->select('stat')->from('TestBundle\\Entity\\Statistics', 'stat')->innerJoin('stat.task', 'task')->innerJoin('task.user', 'user');
     $queryBuilder->where($queryBuilder->expr()->eq('user.id', ':user'))->setParameter(':user', $user->getId(), Type::BIGINT);
     if (!is_null($answer_type) && ($answer_type == 0 || $answer_type == 1)) {
         $queryBuilder->andWhere($queryBuilder->expr()->eq('stat.results', ':results'))->setParameter(':results', boolval($answer_type), Type::BOOLEAN);
     }
     if ($start && $end) {
         $queryBuilder->andWhere($queryBuilder->expr()->between('stat.time', ':start', ':end'))->setParameter(':start', $start, Type::STRING)->setParameter(':end', $end, Type::STRING);
     }
     $query = $queryBuilder->getQuery();
     return $query;
 }
开发者ID:shitikovkirill,项目名称:MedTestPHP,代码行数:25,代码来源:StatisticsRepository.php

示例13: removeDirectly

 public function removeDirectly($type, $id)
 {
     /** @fix detect user id */
     $query = $this->_db->queryAdapter()->delete('tag_items', ['tag' => $this->id, 'item_type' => $type, 'item' => $id], $this->queryAdapterItemsPrefixes());
     $stmt = $this->_db->prepare($query[GC_AFIELD_QUERY]);
     return boolval($stmt->execute($query[GC_AFIELD_PARAMS]));
 }
开发者ID:daemonraco,项目名称:toobasic-tagger,代码行数:7,代码来源:TagRepresentation.php

示例14: formatter_bool_get

function formatter_bool_get($data, $fieldInfo)
{
    if (function_exists('boolval')) {
        return boolval($data);
    }
    return settype($data, 'boolean');
}
开发者ID:jobyone,项目名称:glueframework,代码行数:7,代码来源:CRUDderFormatter.php

示例15: wpas_core_settings_general

/**
 * Add plugin core settings.
 * 
 * @param  (array) $def Array of existing settings
 * @return (array)      Updated settings
 */
function wpas_core_settings_general($def)
{
    $user_registration = boolval(get_option('users_can_register'));
    $registration_lbl = true === $user_registration ? _x('allowed', 'User registration is allowed', 'wpas') : _x('not allowed', 'User registration is not allowed', 'wpas');
    $settings = array('general' => array('name' => __('General', 'wpas'), 'options' => array(array('name' => __('Multiple Products', 'wpas'), 'id' => 'support_products', 'type' => 'checkbox', 'desc' => __('If you need to provide support for multiple products, please enable this option. You will then be able to add your products.', 'wpas'), 'default' => false), array('name' => __('Default Assignee', 'wpas'), 'id' => 'assignee_default', 'type' => 'select', 'desc' => __('Who to assign tickets to by default (if auto-assignment is enabled, this will only be used in case an assignment rule is incorrect).', 'wpas'), 'options' => isset($_GET['post_type']) && 'ticket' === $_GET['post_type'] && isset($_GET['page']) && 'settings' === $_GET['page'] ? wpas_list_users('edit_ticket') : array(), 'default' => ''), array('name' => __('Allow Registrations', 'wpas'), 'id' => 'allow_registrations', 'type' => 'checkbox', 'desc' => sprintf(__('Allow users to register on the support. This setting can be enabled even though the WordPress setting is disabled. Currently, registrations are %s by WordPress.', 'wpas'), "<strong>{$registration_lbl}</strong>"), 'default' => true), array('name' => __('Replies Order', 'wpas'), 'id' => 'replies_order', 'type' => 'radio', 'desc' => __('In which order should the replies be displayed (for both client and admin side)?', 'wpas'), 'options' => array('ASC' => __('Old to New', 'wpas'), 'DESC' => __('New to Old', 'wpas')), 'default' => 'ASC'), array('name' => __('Hide Closed', 'wpas'), 'id' => 'hide_closed', 'type' => 'checkbox', 'desc' => __('Only show open tickets when clicking the "All Tickets" link.', 'wpas'), 'default' => true), array('name' => __('Show Count', 'wpas'), 'id' => 'show_count', 'type' => 'checkbox', 'desc' => __('Display the number of open tickets in the admin menu.', 'wpas'), 'default' => true), array('name' => __('Old Tickets', 'wpas'), 'id' => 'old_ticket', 'type' => 'text', 'default' => 10, 'desc' => __('After how many days should a ticket be considered &laquo;old&raquo;?', 'wpas')), array('name' => __('Plugin Pages', 'wpas'), 'type' => 'heading'), array('name' => __('Ticket Submission', 'wpas'), 'id' => 'ticket_submit', 'type' => 'select', 'desc' => sprintf(__('The page used for ticket submission. This page should contain the shortcode %s', 'wpas'), '<code>[ticket-submit]</code>'), 'options' => wpas_list_pages(), 'default' => ''), array('name' => __('Tickets List', 'wpas'), 'id' => 'ticket_list', 'type' => 'select', 'desc' => sprintf(__('The page that will list all tickets for a client. This page should contain the shortcode %s', 'wpas'), '<code>[tickets]</code>'), 'options' => wpas_list_pages(), 'default' => ''), array('name' => __('Terms & Conditions', 'wpas'), 'type' => 'heading'), array('name' => __('Content', 'wpas'), 'id' => 'terms_conditions', 'type' => 'editor', 'default' => '', 'desc' => __('Terms & conditions are not mandatory. If you add terms, a mendatory checkbox will be added in the registration form. Users won\'t be able to register if they don\'t accept your terms', 'wpas'), 'settings' => array('quicktags' => true, 'textarea_rows' => 7)), array('name' => __('Credit', 'wpas'), 'type' => 'heading'), array('name' => __('Show Credit', 'wpas'), 'id' => 'credit_link', 'type' => 'checkbox', 'desc' => __('You like the plugin? Please help us spread the word by displaying a credit link at the bottom of your ticket submission page.', 'wpas'), 'default' => false))));
    return array_merge($def, $settings);
}
开发者ID:vasikgreif,项目名称:Awesome-Support,代码行数:13,代码来源:settings-general.php


注:本文中的boolval函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。