Dedecms常用函數(shù)解析
Jun 13, 2016 pm 12:30 PM
大家都知道,dedecms支持[field:senddate?function=”strftime('%y-%m-%d?%H:%M',@me)”/]這樣的一些用法,即標記內使用function,調用相關的函數(shù)對當前標簽返回的內容進行再次處理再顯示出來。
???????就拿上面這個標記為例子,本來程序顯示數(shù)據(jù)庫某個表的字段senddate,但通過查看數(shù)據(jù)庫發(fā)現(xiàn),senddate只是一大串數(shù)字,并不是我們想要的時間格式,PHP語言本身對時間處理是有一些自帶的函數(shù),strftime就是php本身自帶的函數(shù),當然你也可以擴展,自己編寫自己的函數(shù),模板上我們不需要顯示這些數(shù)字,我們需要按照一定格式轉換為我們的時間,這時候就可以使用這個函數(shù)進行處理了。
????????下面我們來分析下dedecms自帶一些常用函數(shù)的使用方法:
■GetCurUrl()
這個估計用到的不是太多,這個函數(shù)獲得當前運行的腳本地址,使用時候可以通過下列方式:
{dede:CurUrl?runphp='yes'}
@me?=?GetCurUrl();
{/dede:CurUrl}
■GetAlabNum()
返回半角數(shù)字的,如果你某個字段信息不希望出現(xiàn)全角數(shù)字,可以使用這個函數(shù),例如:
[field:listnum/]返回的是12234,我希望是半角數(shù)字12234,可以這樣使用函數(shù):
[field:listnum?function=”GetAlabNum(@me)”/]
■Text2Html()
文本轉HTML,函數(shù)將文本內容中的空格、…等字符轉換為HTML標記,可以這樣使用:
[field:textcontent?function=”Text2Html(@me)”/]
同樣這里也有個相反的函數(shù),將html轉換為Text的,Html2Text(),其用法類似
■ClearHtml()
清除html標記,函數(shù)將內容中包含的html標記清除。用法:
[field:content?function=”ClearHtml(@me)”/]

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Go language provides two dynamic function creation technologies: closure and reflection. closures allow access to variables within the closure scope, and reflection can create new functions using the FuncOf function. These technologies are useful in customizing HTTP routers, implementing highly customizable systems, and building pluggable components.

1. The SUM function is used to sum the numbers in a column or a group of cells, for example: =SUM(A1:J10). 2. The AVERAGE function is used to calculate the average of the numbers in a column or a group of cells, for example: =AVERAGE(A1:A10). 3. COUNT function, used to count the number of numbers or text in a column or a group of cells, for example: =COUNT(A1:A10) 4. IF function, used to make logical judgments based on specified conditions and return the corresponding result.

The difference between custom PHP functions and predefined functions is: Scope: Custom functions are limited to the scope of their definition, while predefined functions are accessible throughout the script. How to define: Custom functions are defined using the function keyword, while predefined functions are defined by the PHP kernel. Parameter passing: Custom functions receive parameters, while predefined functions may not require parameters. Extensibility: Custom functions can be created as needed, while predefined functions are built-in and cannot be modified.

When passing a map to a function in Go, a copy will be created by default, and modifications to the copy will not affect the original map. If you need to modify the original map, you can pass it through a pointer. Empty maps need to be handled with care, because they are technically nil pointers, and passing an empty map to a function that expects a non-empty map will cause an error.

In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

Exception handling in C++ can be enhanced through custom exception classes that provide specific error messages, contextual information, and perform custom actions based on the error type. Define an exception class inherited from std::exception to provide specific error information. Use the throw keyword to throw a custom exception. Use dynamic_cast in a try-catch block to convert the caught exception to a custom exception type. In the actual case, the open_file function throws a FileNotFoundException exception. Catching and handling the exception can provide a more specific error message.

The key to writing efficient and maintainable Java functions is: keep it simple. Use meaningful naming. Handle special situations. Use appropriate visibility.

Function return value is crucial in C++, which allows the function to return data of a specified type: the return value type defines the type of data returned by the function, including basic types (such as int, float) and custom types (such as pointers, references). The return value meaning varies based on the function's intent, such as returning a result, indicating status, providing a reference, or creating a new object.
