企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
* Table of Content # 1\. HTML输出格式化处理 ## 1.1. 图片 1.JS 中使用image\_thumb(image\_url, w, h) ~~~js function image_thumb(image_url, w, h) { if ('undefined' == typeof w) { w = 60; } if ('undefined' == typeof h) { h = 60; } } ~~~ 2.PHP 中使用 img ~~~PHP /** * Generates an image tag. * @param array|string $src the image URL. This parameter will be processed by [[Url::url()]]. * @param array $options the tag options in terms of name-value pairs. These will be rendered as * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * If a value is null, the corresponding attribute will not be rendered. * See [[renderTagAttributes()]] for details on how attributes are being rendered. * @return string the generated image tag */ public static function img($src, $options = array()) { $options['src'] = $src; if (!isset($options['alt'])) { $options['alt'] = ''; } return static::tag('img', '', $options); } ~~~ ## 1.2. 数字的处理 ### 1.2.1. 时间 ### 1.2.2. 货币 1.format\_money($number , $decimals = 2 , $dec\_point = '.' , $thousands\_sep = ',' ) ~~~php /** * Generates an image tag. * @param number|string $number 货币的数值 * @param int $decimals 小数点后长度,默认为2 * @param string $thousands_sep 千位分隔符,默认为, * @return string */ function format_money($number , $decimals = 2 , $dec_point = '.' , $thousands_sep = ',' ) { if (is_numeric($number)) { return sprintf('<span class="unit">%s</span><span class="price">%s</span>', Base_ConfigModel::getConfig('monetary_unit'), number_format($number, $decimals, $dec_point, $thousands_sep)); } else { return sprintf('<span class="unit">%s</span><span class="price">%s</span>', Base_ConfigModel::getConfig('monetary_unit'), $number); } } ~~~