• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP to_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: build_widget

 function build_widget()
 {
     $id = $this->get('id');
     $attr = array('name' => $this->get('name'), 'id' => $id, 'type' => 'checkbox');
     if ($this->_get('disabled')) {
         $attr['disabled'] = 'disabled';
     }
     if ($this->_get('value')) {
         $attr['checked'] = 'checked';
     }
     /* Note: Checkboxes cannot be set readonly (only from JavaScript) */
     $help = $this->_get('help');
     if (!is_null($help)) {
         $help_text = to_string($help);
         $attr['title'] = $help_text;
         $attr['class'] = 'with-help';
     }
     /* Output */
     $input = new AnewtXHTMLInput(null, $attr);
     $secondary_label = $this->_get('secondary-label');
     if (is_null($secondary_label)) {
         $out = $input;
     } else {
         $label_attr = array();
         if (!is_null($help)) {
             $label_attr['title'] = $help_text;
             $label_attr['class'] = 'with-help';
         }
         $out = new AnewtXHTMLLabel($input, $secondary_label, $label_attr);
     }
     return $out;
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:32,代码来源:choice.lib.php


示例2: debug

/**
 * Formats and simplifies the call stack backtrace log
 *
 * @param  array $backtrace The call stack to simplify
 * @return array            Formatted and simplified backtrace log
 */
function debug($arg1 = null, $arg2 = null)
{
    $vars = func_get_args();
    $bt = array_reverse(debug_backtrace($arg1));
    $c = $bt[count($bt) - 1];
    $call_line = str_replace(DIR_ROOT, '', $c['file']) . ':' . $c['line'];
    print <<<CSS
<style type="text/css">
.Debug     { font-family:sans-serif; border:2px solid #DDD; background-color:#DDD; padding:5px; font-size:13px; }
.Debug H3  { font-size:13px; margin:0 0 10px; padding:0; background-color:#DDD; color:#000; }
.Debug P   { margin:10px 0 0 0; }
.Debug PRE { font-size:14px; padding:3px 4px; margin:5px 0 0 0; background-color:#FFF; font-family:Consolas, monospace; }
</style>
CSS;
    print "<div class=\"Debug\">\n<h3>Debug at {$call_line}</h3>\n";
    foreach ($vars as $var) {
        print "<pre>" . nl2br(to_string($var, true)) . '</pre>';
    }
    $c = 0;
    print "<p>\n";
    foreach ($bt as $step) {
        $file = str_replace(DIR_ROOT, '', $step['file']);
        $line = $step['line'];
        $call = "<strong>" . $step['function'] . '</strong>(' . join(', ', array_map('to_string', $step['args'])) . ')';
        print "#{$c} <strong>{$file}</strong> called {$call} at line <strong>{$line}</strong><br/>\n";
        $c++;
    }
    print '</p>';
    print "</div>";
}
开发者ID:laiello,项目名称:php-garden,代码行数:36,代码来源:pretty-print-variable.php


示例3: build_widget

 /**
  * Build widget HTML for this form control.
  */
 function build_widget()
 {
     /* Output <input ... /> */
     $attr = array('id' => $this->get('id'), 'type' => $this->_get('input-type'), 'class' => sprintf('button %s', $this->_get('extra-class')));
     if ($this->_get('render-name')) {
         $attr['name'] = $this->get('name');
     }
     $label = $this->get('label');
     if (!is_null($label)) {
         $attr['value'] = $label;
     }
     if ($this->get('disabled')) {
         $attr['disabled'] = 'disabled';
     }
     $widget = new AnewtXHTMLInput($attr);
     /* Optional extra class value */
     $class = $this->_get('class');
     if (!is_null($class)) {
         $widget->add_class($class);
     }
     /* Help text, if any */
     $help = $this->_get('help');
     if (!is_null($help)) {
         $help_text = to_string($help);
         $widget->set_attribute('title', $help_text);
         $widget->add_class('with-help');
     }
     return $widget;
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:32,代码来源:button.lib.php


示例4: render

 /**
  * Render this fragment into a string.
  *
  * This method renders all children and concenates those strings into one
  * single value. Usually XHTML fragments are not rendered directly, but
  * added to a DOM tree instead. When that happens, all child nodes of the
  * fragment are added to the DOM tree, and the document fragment instance
  * itself is no longer of any use. This means that this method is not
  * invoked if document fragments are used in combination with a proper DOM
  * document (e.g. as used by AnewtPage).
  *
  * \return
  *   Rendered XML output or an empty string if the fragment was empty.
  */
 function render()
 {
     $out = array();
     foreach ($this->child_nodes as $child_node) {
         $out[] = $child_node->render();
     }
     return to_string($out);
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:22,代码来源:base.lib.php


示例5: init

 function init($args)
 {
     $this->source = $args[0] === null ? '(?:)' : to_string($args[0]);
     $flags = array_key_exists('1', $args) ? to_string($args[1]) : '';
     $this->ignoreCaseFlag = strpos($flags, 'i') !== false;
     $this->globalFlag = strpos($flags, 'g') !== false;
     $this->multilineFlag = strpos($flags, 'm') !== false;
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:8,代码来源:RegExp.php


示例6: __construct

 function __construct($str = null)
 {
     parent::__construct();
     $this->proto = self::$protoObject;
     if (func_num_args() === 1) {
         $this->set('message', to_string($str));
     }
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:8,代码来源:Error.php


示例7: update_core_settings

 public function update_core_settings($setting_key, $setting_value)
 {
     $this->db->where('key', $setting_key);
     $input = array('value' => $setting_value);
     $return = $this->db->update('settings', $input);
     ci()->cfg->{$setting_key} = to_string($setting_value);
     return $return;
 }
开发者ID:dimplewraich,项目名称:finalproject,代码行数:8,代码来源:MY_Model.php


示例8: __construct

 function __construct($value)
 {
     if ($value instanceof Error) {
         $message = $value->getMessage();
     } else {
         $message = to_string($value);
     }
     parent::__construct($message);
     $this->value = $value;
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:10,代码来源:Exception.php


示例9: array_to_string

/**
 * Returns a string representation of an array
 * 
 * @param  array  $array  Array to be stringified
 * @param  bool   $html   Whether to prettify output with HTML and CSS
 * @return string         String representation of input array
 */
function array_to_string($array, $html = false)
{
    $fn = formatter($html ? '<em>%s</em>' : '%s');
    $s1 = $html ? "\n" : '';
    $s2 = $html ? "&nbsp;&nbsp;&nbsp;" : ' ';
    $OUT = array();
    $MAX = array_reduce(array_map('strlen', array_keys($array)), 'max');
    foreach ($array as $key => $val) {
        $SPACER = str_repeat('&nbsp;', max($MAX - strlen($key), 0));
        $OUT[] = to_string($key) . $SPACER . $fn(' = ') . str_replace("\n", $s2, to_string($val));
    }
    return $fn("[{$s2}") . join(",{$s2}", $OUT) . $fn("{$s1}]");
}
开发者ID:laiello,项目名称:php-garden,代码行数:20,代码来源:better_printr-TODO.php


示例10: to_string

 function to_string($arr)
 {
     $values = [];
     foreach ($arr as $k => $v) {
         if (is_array($v)) {
             $v = to_string($v);
         }
         if (is_string($v)) {
             $v = htmlspecialchars($v);
         }
         $v = Database::format($v);
         $values[] = "<b><i>{$k}</i></b>: {$v}";
     }
     return '{' . implode(', ', $values) . '}';
 }
开发者ID:wileybenet,项目名称:mobile-docs,代码行数:15,代码来源:filter.php


示例11: getGlobalConstructor

 /**
  * Creates the global constructor used in user-land
  * @return Func
  */
 static function getGlobalConstructor()
 {
     $String = new Func(function ($value = '') {
         $self = Func::getContext();
         if ($self instanceof Str) {
             $self->value = to_string($value);
             return $self;
         } else {
             return to_string($value);
         }
     });
     $String->instantiate = function () {
         return new Str();
     };
     $String->set('prototype', Str::$protoObject);
     $String->setMethods(Str::$classMethods, true, false, true);
     return $String;
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:22,代码来源:String.php


示例12: init

 function init($args)
 {
     global $Buffer;
     list($subject, $encoding, $offset) = array_pad($args, 3, null);
     $type = gettype($subject);
     if ($type === 'integer' || $type === 'double') {
         $this->raw = str_repeat("", (int) $subject);
     } else {
         if ($type === 'string') {
             $encoding = $encoding === null ? 'utf8' : to_string($encoding);
             if ($encoding === 'hex') {
                 $this->raw = hex2bin($subject);
             } else {
                 if ($encoding === 'base64') {
                     $this->raw = base64_decode($subject);
                 } else {
                     $this->raw = $subject;
                 }
             }
         } else {
             if (_instanceof($subject, $Buffer)) {
                 $this->raw = $subject->raw;
             } else {
                 if ($subject instanceof Arr) {
                     $this->raw = $util['arrToRaw']($subject);
                 } else {
                     throw new Ex(Error::create('Invalid parameters to construct Buffer'));
                 }
             }
         }
     }
     $len = strlen($this->raw);
     //save an integer copy of length for performance
     $this->length = $len;
     $this->set('length', (double) $len);
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:36,代码来源:Buffer.php


示例13: render

 /**
  * Render this node to a string.
  *
  * \return
  *   Rendered string with XML data.
  */
 public function render()
 {
     $node_value_escaped = to_string($this->node_value);
     assert('is_string($node_value_escaped);');
     return $node_value_escaped;
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:12,代码来源:dom.lib.php


示例14: process

 /**
  * Processes the text. This method will transform the input text into XHTML,
  * thereby converting headers, paragraphs, lists, block quotes and other
  * block elements into their corresponding XHTML tags. Hyperlinks, inline
  * markup (like emphasized or strong words), images and code is also
  * converted. Additionally, several typographic enhancements are made to
  * inline text (curly quotes, em dashes, entity replacements, etc).
  *
  * \param $text
  *   Input text in Textile format
  *
  * \return
  *   Processed text in XHTML format
  */
 function process($text)
 {
     /* Normalize */
     $text = $this->_normalize_text($text);
     /* Split into blocks */
     $blocks = $this->_split_into_blocks($text);
     /* Process each block */
     $out = array();
     foreach ($blocks as $block) {
         $out[] = $this->_process_block($block);
     }
     /* Result */
     return to_string($out);
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:28,代码来源:textile.lib.php


示例15: ax_join

/**
 * Join array elements with a string or DOM node.
 *
 * This is an XHTML-aware version of the built-in join() function.
 * 
 * \param $glue
 *   The glue string (or DOM node) to insert between each subsequent pair of
 *   values.
 *
 * \param $values
 *   The values to join together. These can be strings or DOM nodes.
 *
 * \return
 *   A DOM node instance containing the joined values.
 */
function ax_join($glue, $values)
{
    assert('is_numeric_array($values);');
    /* Make sure the glue is escaped properly */
    if ($glue instanceof AnewtXMLDomNode) {
        $glue = to_string($glue);
    } else {
        assert('is_string($glue)');
        $glue = htmlspecialchars($glue);
    }
    /* Build a format string so that ax_vsprintf() can do the real work */
    $glue = str_replace('%', '%%', $glue);
    $format = join($glue, array_fill(0, count($values), '%s'));
    return ax_vsprintf(ax_raw($format), $values);
}
开发者ID:jijkoun,项目名称:ssscrape,代码行数:30,代码来源:api.lib.php


示例16: checkInt

 static function checkInt($s)
 {
     if (is_int($s) && $s >= 0) {
         return (double) $s;
     }
     $s = to_string($s);
     $match = preg_match('/^\\d+$/', $s);
     return $match !== false ? (double) $s : null;
 }
开发者ID:mk-pmb,项目名称:js2php,代码行数:9,代码来源:Array.php


示例17: _build_form_control_node

 /**
  * Build XHTML for a form control.
  *
  * \param $control
  *   An AnewtFormControl instance.
  */
 protected function _build_form_control_node($control)
 {
     $control_div = ax_div_class(null, 'form-control');
     $control_div->append_child($this->_build_description_node($control));
     $control_div->append_child($this->_build_error_node($control));
     /* Label and the widget itself are combined. Buttons do not have
      * explicit labels, since the label text is on the button itself. */
     $widget = $control->build_widget();
     $label_text = $control->_get('label');
     if (is_null($label_text) || $control instanceof AnewtFormControlButton) {
         /* No label (none set or this is a button) */
         $control_div->append_child($widget);
     } else {
         /* This control has a label */
         assert('is_string($label_text) || $label_text instanceof AnewtXMLDomNode');
         $label = new AnewtXHTMLLabel($label_text, array('class' => 'form-control'));
         /* Some composite widgets support allow the 'for=' attribute to be
          * filled in, even though they consist of multiple html widgets. */
         if ($control->get('composite')) {
             $composite_for = $control->get('composite-for');
             if (!is_null($composite_for)) {
                 $label->set_attribute('for', $composite_for);
             }
         } else {
             $label->set_attribute('for', $control->get('id'));
         }
         /* Help text */
         $help = $control->_get('help');
         if (!is_null($help)) {
             $help_text = to_string($help);
             $label->set_attribute('title', $help_text);
             $label->add_class('with-help');
         }
         $control_div->append_child($label);
         $control_div->append_child($widget);
         unset($label);
     }
     unset($widget);
     return $control_div;
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:46,代码来源:default.lib.php


示例18: build_widget

 function build_widget()
 {
     $value = $this->_get('value');
     if (is_null($value)) {
         $value = "";
     }
     assert('is_string($value); // only plain strings can be used as field value: type: ' . gettype($value));
     $name = $this->get('name');
     $widgets = array();
     if ($this->get('show-img-preview') && $value) {
         $widgets[] = ax_div_class(ax_img_src($this->get('preview-dir') . $value), 'preview');
     } elseif ($this->get('show-link-preview') && $value) {
         $widgets[] = ax_div_class(ax_a_href($value, $this->get('preview-dir') . $value), 'preview');
     }
     $remove_label = $this->_get('remove-label');
     if ($remove_label && $value) {
         $subattr = array('type' => 'checkbox', 'name' => $name . '-remove');
         $widgets[] = new AnewtXHTMLInput(null, $subattr);
         $subattr = array('for' => $name . '-remove');
         $widgets[] = new AnewtXHTMLLabel($remove_label, $subattr);
         $widgets[] = ax_br();
     }
     /* XML tag attributes used both for single line and multiline */
     $attr = array('name' => $this->get('name'), 'id' => $this->get('id'), 'type' => 'file');
     if ($this->_get('readonly')) {
         $attr['readonly'] = 'readonly';
     }
     if ($this->_get('disabled')) {
         $attr['disabled'] = 'disabled';
     }
     $size = $this->_get('size');
     if (!is_null($size)) {
         assert('is_int($size);');
         $attr['size'] = (string) $size;
     }
     $maxlength = $this->_get('maxlength');
     if (!is_null($maxlength)) {
         assert('is_int($maxlength);');
         $attr['maxlength'] = (string) $maxlength;
     }
     $max_file_size = $this->_get('max_file_size');
     if (!is_null($max_file_size)) {
         $subattr = array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => (string) $max_file_size);
         $widgets[] = new AnewtXHMTLInput(null, $subattr);
     }
     $widget = new AnewtXHTMLInput(null, $attr);
     /* Styling */
     $widget->add_class('fileupload');
     if (!$this->_get('required')) {
         $widget->add_class('optional');
     }
     /* Optional extra class value */
     $class = $this->_get('class');
     if (!is_null($class)) {
         $widget->add_class($class);
     }
     /* Help text, if any */
     $help = $this->_get('help');
     if (!is_null($help)) {
         $help_text = to_string($help);
         $widget->set_attribute('title', $help_text);
         $widget->add_class('with-help');
     }
     $widgets[] = $widget;
     /* Add secondary label, if any */
     $secondary_label = $this->_get('secondary-label');
     if (!is_null($secondary_label)) {
         $widgets[] = $secondary_label;
     }
     $out = ax_fragment($widgets);
     return $out;
 }
开发者ID:jijkoun,项目名称:ssscrape,代码行数:72,代码来源:fileupload.lib.php


示例19: to_int

<?php

// implicitly weak mode code
function to_int(int &$x)
{
}
function to_float(float &$x)
{
}
function to_string(string &$x)
{
}
function to_bool(bool &$x)
{
}
$x = 1.0;
var_dump($x);
to_int($x);
// because $x is by-reference, the weak type hint converts it
var_dump($x);
to_float($x);
var_dump($x);
to_string($x);
var_dump($x);
to_bool($x);
var_dump($x);
开发者ID:badlamer,项目名称:hhvm,代码行数:26,代码来源:scalar_weak_reference.php


示例20: ax_sprintf

/**
 * Format a text node using a format specifier and supplied values.
 *
 * This method acts like sprintf(), but supports DOM nodes and takes care of XML
 * escaping. This function formats its arguments into a (raw) DOM node instead
 * of a string. The supplied values may regular values such as strings and
 * numbers, but may be XML nodes as well. This means you can pass XML node
 * instances created by the functions in the xhtml module as values. The format
 * specifier will be escaped for XML, and XML nodes will be rendered into
 * escaped strings before substitution into the format specifier.
 *
 * This example results in a valid XHTML paragraph:
 *
 * <code>
 * ax_p(ax_sprintf('%s & %s', ax_span_class('Sugar', 'sweet'), 'Spice'));
 * </code>
 *
 * \param $format
 *   A format specifier in sprintf syntax.
 *
 * \param $values
 *   One or more values to be substituted into the format string.
 *
 * \return
 *   An AnewtXHTMLRaw instance that can be added to a DOM tree (or page).
 */
function ax_sprintf($format, $values)
{
    /* Accept multiple parameters, just like sprintf */
    $values = func_get_args();
    /* First parameter is the format */
    $format = array_shift($values);
    if ($format instanceof AnewtXMLDomNode) {
        $format = to_string($format);
    } else {
        assert('is_string($format)');
        $format = htmlspecialchars($format);
    }
    /* Render DOM nodes into strings. The $values array is modified in-place. */
    foreach (array_keys($values) as $key) {
        if (is_string($values[$key])) {
            $values[$key] = htmlspecialchars($values[$key]);
        } elseif ($values[$key] instanceof AnewtXMLDomNode) {
            $values[$key] = to_string($values[$key]);
        }
    }
    /* Everything is already escaped, so return a raw node */
    return ax_raw(vsprintf($format, $values));
}
开发者ID:jijkoun,项目名称:ssscrape,代码行数:49,代码来源:api.lib.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP to_time函数代码示例发布时间:2022-05-23
下一篇:
PHP to_sqls函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap