selecting data from mysql db using regular expression


A regular expression is a powerful way of specifying a pattern for a complex search. Below is a simple example. select email from foo where email REGEXP ‘foo.com$’; In the above example, It will list all the email which ends with foo.com. “$” sign is used to denote the end of the string. Advertisements

default modifier in smarty


“default” used to set a default value for a variable. If the variable is unset or an empty string, then the default would be display. This modifier accepts one parameter which is the default value to show. {$foo|default:’Default text’}

Count number of characters in a string in smarty


We can count number of characters in a string through the smarty. Smarty provide a modifier called “count_characters”. {$str|count_characters} Above statement will display the number of characters in the string excluding the white-spaces. {$str|count_characters:true} Above statement will display the number of characters in the string including the white-spaces.

Capture in Smarty


{capture} is used to collect the output of the template between the tags into a variable. All content between {capture name=’test’} and {/capture} would into the variable in specified catpure name. The captured content can be used in the template from the variable {$smarty.capture.test} where “test” is the name of that capture. If we don’t provide the name attribute, then “default” will be used as the…