* 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);
}
}
~~~
- 开发文档
- /输出格式化处理
- /MySQL.md
- /tpl.md
- /locale.md
- /试衣镜.md
- /note.md
- /api/shop.md
- Table of Content
- shop 项目
- 1.1. ActivityCtl
- 1.2. CartCtl
- 1.3. CategoryCtl
- 1.4. ChainCtl
- 1.5. ChooseIndustryCtl
- 1.6. Distribution_UserCtl
- 1.7. IndexCtl
- 1.8. JoinController
- 1.9. JoinCtl
- 1.10. LoginCtl
- 1.11. MediaCtl
- 1.12. PageCtl
- 1.13. PlatformController
- 1.14. PointController
- 1.15. PointCtl
- 1.16. ProductCtl
- 1.17. SitemapCtl
- 1.18. StoreController
- 1.19. StoreCtl
- 1.20. UrlCtl
- 1.21. User_AccountCtl
- 1.22. User_ActivityCtl
- 1.23. User_AskCtl
- 1.24. User_CommentCtl
- 1.25. User_DeliveryAddressCtl
- 1.26. User_FavoritesCtl
- 1.27. User_FeedbackCtl
- 1.28. User_InvoiceCtl
- 1.29. User_OrderCtl
- 1.30. User_ResourceCtl
- 1.31. User_ReturnCtl
- 1.32. User_VoucherCtl
- 1.33. UserCenterController
- 1.34. UserCtl
- 1.35. VerifyCodeCtl
- 1.36. WechatCallbackCtl
- /框架核心说明.md