Home > Backend Development > PHP Tutorial > Dedecms common function analysis_PHP tutorial

Dedecms common function analysis_PHP tutorial

WBOY
Release: 2016-07-21 15:53:29
Original
910 people have browsed it

As we all know, dedecms supports some usages such as [field:senddate function=”strftime('%y-%m-%d %H:%M',@me)”/], that is, using functions within tags and calling related The function reprocesses the content returned by the current tag and then displays it.

Take the above mark as an example. Originally, the program displayed the senddate field in a table in the database, but by looking at the database, we found that senddate is just a large series of numbers, not the time format we want. The PHP language itself has There are some built-in functions for time processing. strftime is a function that comes with PHP itself. Of course, you can also extend it and write your own functions. We don’t need to display these numbers on the template. We need to convert them into our time according to a certain format. , then you can use this function for processing.


Now let’s analyze how to use some common functions that come with dedecms:

■GetCurUrl()

This is probably not used too much. The function obtains the address of the currently running script. You can use it in the following ways:
{dede:CurUrl runphp='yes'}
@me = GetCurUrl();
{/dede:CurUrl}

■GetAlabNum()

Returns half-width numbers. If you do not want full-width numbers to appear in a certain field information, you can use this function, for example:
[field:listnum/] returns 12234 , I hope it is a half-width number 12234. You can use the function like this:
[field:listnum function=”GetAlabNum(@me)”/]

■Text2Html()

Text to HTML , the function converts characters such as spaces, <, >... in the text content into HTML tags. It can be used like this:
[field:textcontent function=”Text2Html(@me)”/]
The same is here A reverse function that converts html to Text, Html2Text(), its usage is similar to

■ClearHtml()

Clear html tags, the function clears the html tags contained in the content. Usage:
[field:content function=”ClearHtml(@me)”/]

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318703.htmlTechArticleAs we all know, dedecms supports [field:senddatefunction=”strftime('%y-%m-%d% H:%M',@me)"/] Such usage is to use function within the tag and call the relevant function to return the current tag...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template