What is Smarty?
Why use it?
Use Cases and Work Flow
Syntax Comparison
Template Inheritance
Best Practices
Crash Course
You may use the Smarty logo according to the trademark notice.
For sponsorship, advertising, news or other inquiries, contact us at:
Un simple remplacement de chaîne de caractères. C'est l'équivalent
de la fonction PHP
str_replace()
.
Position du paramètre | Type | Requis | Defaut | Description |
---|---|---|---|---|
1 | chaîne de caractères | Oui | n/a | chaîne à remplacer. |
2 | chaîne de caractères | Oui | n/a | chaîne de remplacement. |
Example 5.16. replace
<?php $smarty->assign('titreArticle', "Child's Stool Great for Use in Garden."); ?>
Ou le template est :
{$titreArticle} {$titreArticle|replace:'Garden':'Vineyard'} {$titreArticle|replace:' ':' '}
Affichera :
Child's Stool Great for Use in Garden. Child's Stool Great for Use in Vineyard. Child's Stool Great for Use in Garden.
Voir aussi
regex_replace
et
escape
.