Manuel PHP
bbcode_add_smiley
(No version information available, might be only in CVS)
bbcode_add_smiley — Adds a smiley to the parser
Description
bool bbcode_add_smiley
( resource $bbcode_container
, string $smiley
, string $replace_by
)
Adds a smiley to the parser
Liste de paramètres
- bbcode_container
-
BBCode_Container resource, returned by bbcode_create().
- smiley
-
The string that will be replaced when found.
- replace_by
-
The string that replace smiley when found.
Valeurs de retour
Cette fonction retourne TRUE en cas de succès, FALSE en cas d'échec.
Exemples
Example#1 bbcode_add_smiley() usage example
- <?php
- /*
- * Prepare the rule set
- */
- $arrayBBCode=array(
- ''=> array('type'=>BBCODE_TYPE_ROOT,
- 'childs'=>'!i'),
- 'b'=> array('type'=>BBCODE_TYPE_NOARG,
- 'open_tag'=>'<b>',
- 'close_tag'=>'</b>'),
- 'u'=> array('type'=>BBCODE_TYPE_NOARG,
- 'open_tag'=>'<u>',
- 'close_tag'=>'</u>',
- 'flags'=>BBCODE_FLAGS_SMILEYS_OFF),
- 'i'=> array('type'=>BBCODE_TYPE_NOARG,
- 'open_tag'=>'<i>',
- 'close_tag'=>'</i>',
- 'childs'=>'b'),
- );
- /*
- * Parsed Text
- */
- $text=<<<EOF
- No parse Test :)
- Parsed, with smiley :(
- Parsed, with no smiley :D
- EOF;
- /*
- * Init the parser
- */
- $BBHandler=bbcode_create($arrayBBCode);
- /*
- * Add Smiley rules to parser
- */
- bbcode_add_smiley($BBHandler, ":)", "<img src=\"smiley.gif\" alt=\":)\" />");
- bbcode_add_smiley($BBHandler, ":(", "<img src=\"sad.gif\" alt=\":(\" />");
- bbcode_add_smiley($BBHandler, ":D", "<img src=\"happy.gif\" alt=\":D\" />");
- bbcode_add_smiley($BBHandler, ":p", "<img src=\"tong.gif\" alt=\":p\" />");
- bbcode_add_smiley($BBHandler, ":|", "<img src=\"special.gif\" alt=\":|\" />");
- bbcode_add_smiley($BBHandler, ":6:", "<img src=\"six.gif\" alt=\":6:\" />");
- /*
- * Parse the text
- */
- echo bbcode_parse($BBHandler,$text);
- ?>
L'exemple ci-dessus va afficher :
No parse Test <img src="smiley.gif" alt=":)" />
<b> Parsed, with smiley <img src="sad.gif" alt=":(" /> </b>
<u> Parsed, with no smiley :D </u>
Remonter 
