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


PHP is_string函数代码示例

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


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

示例1: vc_dropdown_form_field

/**
 * Dropdown(select with options) shortcode attribute type generator.
 *
 * @param $settings
 * @param $value
 *
 * @since 4.4
 * @return string - html string.
 */
function vc_dropdown_form_field($settings, $value)
{
    $output = '';
    $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value));
    $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">';
    if (is_array($value)) {
        $value = isset($value['value']) ? $value['value'] : array_shift($value);
    }
    if (!empty($settings['value'])) {
        foreach ($settings['value'] as $index => $data) {
            if (is_numeric($index) && (is_string($data) || is_numeric($data))) {
                $option_label = $data;
                $option_value = $data;
            } elseif (is_numeric($index) && is_array($data)) {
                $option_label = isset($data['label']) ? $data['label'] : array_pop($data);
                $option_value = isset($data['value']) ? $data['value'] : array_pop($data);
            } else {
                $option_value = $data;
                $option_label = $index;
            }
            $selected = '';
            $option_value_string = (string) $option_value;
            $value_string = (string) $value;
            if ('' !== $value && $option_value_string === $value_string) {
                $selected = ' selected="selected"';
            }
            $option_class = str_replace('#', 'hash-', $option_value);
            $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>';
        }
    }
    $output .= '</select>';
    return $output;
}
开发者ID:severnrescue,项目名称:web,代码行数:42,代码来源:default_params.php

示例2: __construct

 /**
  * @param mixed $in
  */
 public function __construct($in = null)
 {
     $fields = array('to', 'cc', 'bcc', 'message', 'body', 'subject');
     if (is_string($in)) {
         if (($pos = strpos($in, '?')) !== false) {
             parse_str(substr($in, $pos + 1), $this->args);
             $this->args['to'] = substr($in, 0, $pos);
         } else {
             $this->args['to'] = $in;
         }
     } elseif ($in instanceof Horde_Variables) {
         foreach ($fields as $val) {
             if (isset($in->{$val})) {
                 $this->args[$val] = $in->{$val};
             }
         }
     } elseif (is_array($in)) {
         $this->args = $in;
     }
     if (isset($this->args['to']) && strpos($this->args['to'], 'mailto:') === 0) {
         $mailto = @parse_url($this->args['to']);
         if (is_array($mailto)) {
             $this->args['to'] = isset($mailto['path']) ? $mailto['path'] : '';
             if (!empty($mailto['query'])) {
                 parse_str($mailto['query'], $vals);
                 foreach ($fields as $val) {
                     if (isset($vals[$val])) {
                         $this->args[$val] = $vals[$val];
                     }
                 }
             }
         }
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:37,代码来源:Link.php

示例3: partial

 public function partial($partial, $__time = false, $params = null, $group = 'kumbia.partials')
 {
     //        if (PRODUCTION && $__time && !Cache::driver()->start($__time, $partial, $group)) {
     //            return;
     //        }
     //Verificando el partials en el dir app
     $__file = $this->viewPath . "/_shared/partials/{$partial}.phtml";
     //        if (!is_file($__file)) {
     //            //Verificando el partials en el dir core
     //            $__file = CORE_PATH . "views/partials/$partial.phtml";
     //        }
     if ($params) {
         if (is_string($params)) {
             $params = Util::getParams(explode(',', $params));
         }
         // carga los parametros en el scope
         extract($params, EXTR_OVERWRITE);
     }
     // carga la vista parcial
     if (!(include $__file)) {
         throw new \Exception('Vista Parcial "' . $__file . '" no se encontro');
     }
     // se guarda en la cache de ser requerido
     //        if (PRODUCTION && $__time) {
     //            Cache::driver()->end();
     //        }
 }
开发者ID:Ashrey,项目名称:kumbia_pimple,代码行数:27,代码来源:View.php

示例4: _getSearchParam

 /**
  * Retrieve filter array
  *
  * @param Enterprise_Search_Model_Resource_Collection $collection
  * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
  * @param string|array $value
  * @return array
  */
 protected function _getSearchParam($collection, $attribute, $value)
 {
     if (!is_string($value) && empty($value) || is_string($value) && strlen(trim($value)) == 0 || is_array($value) && isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
         return array();
     }
     if (!is_array($value)) {
         $value = array($value);
     }
     $field = Mage::getResourceSingleton('enterprise_search/engine')->getSearchEngineFieldName($attribute, 'nav');
     if ($attribute->getBackendType() == 'datetime') {
         $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
         foreach ($value as &$val) {
             if (!is_empty_date($val)) {
                 $date = new Zend_Date($val, $format);
                 $val = $date->toString(Zend_Date::ISO_8601) . 'Z';
             }
         }
         unset($val);
     }
     if (empty($value)) {
         return array();
     } else {
         return array($field => $value);
     }
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:33,代码来源:Advanced.php

示例5: init

 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $settings array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
 public function init($settings = array())
 {
     if (!class_exists('Memcache')) {
         return false;
     }
     if (!isset($settings['prefix'])) {
         $settings['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     $settings += array('engine' => 'Memcache', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true);
     parent::init($settings);
     if ($this->settings['compress']) {
         $this->settings['compress'] = MEMCACHE_COMPRESSED;
     }
     if (is_string($this->settings['servers'])) {
         $this->settings['servers'] = array($this->settings['servers']);
     }
     if (!isset($this->_Memcache)) {
         $return = false;
         $this->_Memcache = new Memcache();
         foreach ($this->settings['servers'] as $server) {
             list($host, $port) = $this->_parseServerString($server);
             if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) {
                 $return = true;
             }
         }
         return $return;
     }
     return true;
 }
开发者ID:4Queen,项目名称:php-buildpack,代码行数:38,代码来源:MemcacheEngine.php

示例6: handle

 /**
  * The handler which sets all the values in the dynamic definition.
  *
  * @param String $class the Controller class name
  * @param LaravelSwagger $LS the LaravelSwagger instance.
  * @throws DynamicHandlerException
  */
 public function handle($class, LaravelSwagger $LS)
 {
     /**
      *************************************
      *         Default Behaviour         *
      *************************************
      *
      * Loops through all of the linked keys
      */
     foreach ($this->method->keys() as $key) {
         /** @var mixed $value the value associated with the specific key */
         $value = ValueContainer::getValue($class, $key);
         if (is_string($value)) {
             //if its a string of a class
             //if it is a model that has been registered.
             if (is_subclass_of($value, Model::class) && $LS->hasModel($value)) {
                 $value = "#/definitions/{$value}";
             }
         }
         //if there is no value then throw an exception
         if (is_null($value)) {
             throw new DynamicHandlerException("{$key} value is NULL");
         }
         $this->method->set($key, $value);
     }
 }
开发者ID:kevupton,项目名称:laravel-swagger,代码行数:33,代码来源:DynamicHandler.php

示例7: initColumns

 protected function initColumns()
 {
     if (empty($this->columns)) {
         if ($this->dataProvider instanceof CActiveDataProvider) {
             $this->columns = $this->dataProvider->model->attributeNames();
         } elseif ($this->dataProvider instanceof IDataProvider) {
             $data = $this->dataProvider->getData();
             if (isset($data[0]) && is_array($data[0])) {
                 $this->columns = array_keys($data[0]);
             }
         }
     }
     foreach ($this->columns as $i => $column) {
         if (is_string($column)) {
             $this->_columns[] = $column;
         } elseif (is_array($column)) {
             if ($column['header']) {
                 $this->_columns[] = $column['header'];
             } else {
                 $this->_columns[] = $column['name'];
             }
             if ($this->dataProvider instanceof CActiveDataProvider) {
                 if (!$this->_columns[$i]) {
                     $this->_columns[$i] = $this->dataProvider->model->getAttributeLabel($column['name']);
                 }
                 $this->_select[] = $column['name'];
             }
         }
     }
 }
开发者ID:fourteenmeister,项目名称:yii-handsontable,代码行数:30,代码来源:Handsontable.php

示例8: e

 public function e($var)
 {
     if (!is_string($var)) {
         throw new Exception('$var must be a string.');
     }
     return htmlspecialchars($var, ENT_QUOTES);
 }
开发者ID:JosePathe,项目名称:phpdim2016,代码行数:7,代码来源:PhpRenderer.php

示例9: setChannel

 /**
  * @param string $channel
  *
  * @return Event
  */
 public function setChannel($channel)
 {
     if ((is_string($channel) || is_numeric($channel)) && !empty($channel)) {
         $this->addMetaData('channel', $channel);
     }
     return $this;
 }
开发者ID:reactorcoder,项目名称:symfony2-nodesocket,代码行数:12,代码来源:Event.php

示例10: formatMessage

 public static function formatMessage(Rule $rule, $withValue = TRUE)
 {
     $message = $rule->message;
     if ($message instanceof Nette\Utils\Html) {
         return $message;
     } elseif ($message === NULL && is_string($rule->validator) && isset(static::$messages[$rule->validator])) {
         $message = static::$messages[$rule->validator];
     } elseif ($message == NULL) {
         // intentionally ==
         trigger_error("Missing validation message for control '{$rule->control->getName()}'.", E_USER_WARNING);
     }
     if ($translator = $rule->control->getForm()->getTranslator()) {
         $message = $translator->translate($message, is_int($rule->arg) ? $rule->arg : NULL);
     }
     $message = preg_replace_callback('#%(name|label|value|\\d+\\$[ds]|[ds])#', function ($m) use($rule, $withValue) {
         static $i = -1;
         switch ($m[1]) {
             case 'name':
                 return $rule->control->getName();
             case 'label':
                 return $rule->control->translate($rule->control->caption);
             case 'value':
                 return $withValue ? $rule->control->getValue() : $m[0];
             default:
                 $args = is_array($rule->arg) ? $rule->arg : array($rule->arg);
                 $i = (int) $m[1] ? $m[1] - 1 : $i + 1;
                 return isset($args[$i]) ? $args[$i] instanceof IControl ? $withValue ? $args[$i]->getValue() : "%{$i}" : $args[$i] : '';
         }
     }, $message);
     return $message;
 }
开发者ID:rostenkowski,项目名称:nette,代码行数:31,代码来源:Validator.php

示例11: PMA_gpc_extract

function PMA_gpc_extract($array, &$target, $sanitize = TRUE)
{
    if (!is_array($array)) {
        return FALSE;
    }
    $is_magic_quotes = get_magic_quotes_gpc();
    foreach ($array as $key => $value) {
        /**
         * 2005-02-22, rabus:
         *
         * This is just an ugly hotfix to avoid changing internal config
         * parameters.
         *
         * Currently, the following variable names are rejected when found in
         * $_GET or $_POST: cfg, GLOBALS, str* and _*
         */
        if ($sanitize && is_string($key) && ($key == 'cfg' || $key == 'GLOBALS' || substr($key, 0, 3) == 'str' || $key[0] == '_')) {
            continue;
        }
        if (is_array($value)) {
            // there could be a variable coming from a cookie of
            // another application, with the same name as this array
            unset($target[$key]);
            PMA_gpc_extract($value, $target[$key], FALSE);
        } else {
            if ($is_magic_quotes) {
                $target[$key] = stripslashes($value);
            } else {
                $target[$key] = $value;
            }
        }
    }
    return TRUE;
}
开发者ID:mike503,项目名称:phpmyadmin,代码行数:34,代码来源:grab_globals.lib.php

示例12: __construct

 public function __construct($a = '')
 {
     parent::__construct();
     $this->a = $a;
     /* parse the before and after graphs if necessary*/
     foreach (array('before', 'after', 'before_rdfxml', 'after_rdfxml') as $rdf) {
         if (!empty($a[$rdf])) {
             if (is_string($a[$rdf])) {
                 /** @var \ARC2_RDFParser $parser */
                 $parser = \ARC2::getRDFParser();
                 $parser->parse(false, $a[$rdf]);
                 $a[$rdf] = $parser->getSimpleIndex(0);
             } else {
                 if (is_array($a[$rdf]) and isset($a[$rdf][0]) and isset($a[$rdf][0]['s'])) {
                     //triples array
                     /** @var \ARC2_RDFSerializer $ser */
                     $ser = \ARC2::getTurtleSerializer();
                     /** @var string $turtle */
                     $turtle = $ser->getSerializedTriples($a[$rdf]);
                     /** @var \ARC2_RDFParser $parser */
                     $parser = \ARC2::getTurtleParser();
                     $parser->parse(false, $turtle);
                     $a[$rdf] = $parser->getSimpleIndex(0);
                 }
             }
             $nrdf = str_replace('_rdfxml', '', $rdf);
             $this->{$nrdf} = $a[$rdf];
         }
     }
     $this->__init();
 }
开发者ID:talis,项目名称:tripod-php,代码行数:31,代码来源:ChangeSet.class.php

示例13: __construct

 /**
  * Creates a Redisent interface to a cluster of Redis servers
  * @param array $servers The Redis servers in the cluster. Each server should be in the format array('host' => hostname, 'port' => port)
  */
 function __construct($servers)
 {
     $this->ring = array();
     $this->aliases = array();
     foreach ($servers as $alias => $server) {
         $this->redisents[] = new Redisent($server['host'], $server['port']);
         if (is_string($alias)) {
             // 用key作为alias标记redis实例
             $this->aliases[$alias] = $this->redisents[count($this->redisents) - 1];
         }
         for ($replica = 1; $replica <= $this->replicas; $replica++) {
             // crc32 — 计算一个字符串的 crc32 多项式,生成 str 的 32 位循环冗余校验码多项式。这通常用于检查传输的数据是否完整。返回值为int类型。
             $this->ring[crc32($server['host'] . ':' . $server['port'] . '-' . $replica)] = $this->redisents[count($this->redisents) - 1];
         }
     }
     // ksort — 对数组按照键名排序
     // 排序类型标记:
     // SORT_REGULAR - 正常比较单元(不改变类型)
     // SORT_NUMERIC - 单元被作为数字来比较
     // SORT_STRING - 单元被作为字符串来比较
     // SORT_LOCALE_STRING - 根据当前的区域(locale)设置来把单元当作字符串比较,可以用 setlocale() 来改变。
     // SORT_NATURAL - 和 natsort() 类似对每个单元以“自然的顺序”对字符串进行排序。 PHP 5.4.0 中新增的。
     // SORT_FLAG_CASE - 能够与 SORT_STRING 或 SORT_NATURAL 合并(OR 位运算),不区分大小写排序字符串。
     ksort($this->ring, SORT_NUMERIC);
     // 将redis实例集合的索引放到$this->nodes中
     $this->nodes = array_keys($this->ring);
 }
开发者ID:CraryPrimitiveMan,项目名称:php-resque-1.2-annotated,代码行数:31,代码来源:RedisentCluster.php

示例14: __construct

 /**
  * Constructor
  *
  * @param  string|array|Zend_Config $spec Element name or configuration
  * @param  string|array|Zend_Config $options Element value or configuration
  * @return void
  */
 public function __construct($spec, $options = null)
 {
     if (is_string($spec) && (null !== $options && is_string($options))) {
         $options = array('label' => $options);
     }
     parent::__construct($spec, $options);
 }
开发者ID:crlang44,项目名称:frapi,代码行数:14,代码来源:Button.php

示例15: getInstance

 /**
  * Returns an instance of KeyInfo object based on the input KeyInfo XML block
  *
  * @param string $xmlData The KeyInfo XML Block
  * @return Zend_InfoCard_Xml_KeyInfo_Abstract
  * @throws Zend_InfoCard_Xml_Exception
  */
 public static function getInstance($xmlData)
 {
     if ($xmlData instanceof Zend_InfoCard_Xml_Element) {
         $strXmlData = $xmlData->asXML();
     } else {
         if (is_string($xmlData)) {
             $strXmlData = $xmlData;
         } else {
             throw new Zend_InfoCard_Xml_Exception("Invalid Data provided to create instance");
         }
     }
     $sxe = simplexml_load_string($strXmlData);
     $namespaces = $sxe->getDocNameSpaces();
     if (!empty($namespaces)) {
         foreach ($sxe->getDocNameSpaces() as $namespace) {
             switch ($namespace) {
                 case 'http://www.w3.org/2000/09/xmldsig#':
                     include_once 'Zend/InfoCard/Xml/KeyInfo/XmlDSig.php';
                     return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_KeyInfo_XmlDSig');
                 default:
                     throw new Zend_InfoCard_Xml_Exception("Unknown KeyInfo Namespace provided");
                     // We are ignoring these lines, as XDebug reports each as a "non executed" line
                     // which breaks my coverage %
                     // @codeCoverageIgnoreStart
             }
         }
     }
     // @codeCoverageIgnoreEnd
     include_once 'Zend/InfoCard/Xml/KeyInfo/Default.php';
     return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_KeyInfo_Default');
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:38,代码来源:KeyInfo.php


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