本文整理汇总了PHP中to_string函数的典型用法代码示例。如果您正苦于以下问题:PHP to_string函数的具体用法?PHP to_string怎么用?PHP to_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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>";
}
示例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;
}
示例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);
}
示例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;
}
示例6: __construct
function __construct($str = null)
{
parent::__construct();
$this->proto = self::$protoObject;
if (func_num_args() === 1) {
$this->set('message', to_string($str));
}
}
示例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;
}
示例8: __construct
function __construct($value)
{
if ($value instanceof Error) {
$message = $value->getMessage();
} else {
$message = to_string($value);
}
parent::__construct($message);
$this->value = $value;
}
示例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 ? " " : ' ';
$OUT = array();
$MAX = array_reduce(array_map('strlen', array_keys($array)), 'max');
foreach ($array as $key => $val) {
$SPACER = str_repeat(' ', 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}]");
}
示例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) . '}';
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}