Manuel PHP

bbcode_set_flags

(No version information available, might be only in CVS)

bbcode_set_flags — Set or alter parser options

Description

bool bbcode_set_flags ( resource $bbcode_container , int $flags [, int $mode ] )

Set or alter parser options

Liste de paramètres

bbcode_container

BBCode_Container resource, returned by bbcode_create().

flags

The flag set that must be applied to the bbcode_container options

mode

One of the BBCODE_SET_FLAGS_* constant to set, unset a specific flag set or to replace the flag set by flags.

Valeurs de retour

Cette fonction retourne TRUE en cas de succès, FALSE en cas d'échec.

Exemples

Example#1 bbcode_set_flags() usage example

  1. <?php
  2. /*
  3. * Preparing RuleSet
  4. */  
  5. $arrayBBCode=array( 
  6.    'b'=>      array('type'=>BBCODE_TYPE_NOARG, 
  7.                'open_tag'=>'<b>', 'close_tag'=>'</b>'), 
  8.    'u'=>      array('type'=>BBCODE_TYPE_NOARG, 
  9.                'open_tag'=>'<u>', 'close_tag'=>'</u>'), 
  10.    'i'=>      array('type'=>BBCODE_TYPE_NOARG, 
  11.                'open_tag'=>'<i>', 'close_tag'=>'</i>'),  
  12. );  
  13. /*
  14. * Paired incorrectly nested BBCode
  15. */  
  16. $text=" Parser Auto Correction at work \n";  
  17. $BBHandler=bbcode_create($arrayBBCode);  
  18. echo bbcode_parse($BBHandler,$text);  
  19. // Enabling reopening of automaticaly closed elements
  20. bbcode_set_flags($BBHandler,BBCODE_CORRECT_REOPEN_TAGS, 
  21.             BBCODE_SET_FLAGS_SET);  
  22. echo bbcode_parse($BBHandler,$text);  
  23.  
  24. /*
  25. * Unpaired incorrectly nested BBCode
  26. */  
  27. $text=" Parser [b] Auto Correction at work\n";  
  28. echo bbcode_parse($BBHandler,$text);  
  29. // Enabling automatic close of pending tags
  30. bbcode_set_flags($BBHandler, 
  31.             BBCODE_CORRECT_REOPEN_TAGS|BBCODE_AUTO_CORRECT, 
  32.             BBCODE_SET_FLAGS_SET);  
  33. echo bbcode_parse($BBHandler,$text);  
  34. ?> 

L'exemple ci-dessus va afficher :

<i> Parser <b> Auto Correction </b></i> at work <i> Parser <b> Auto Correction </b></i><b> at work </b> <i> Parser [b] Auto Correction </i> at work <i> Parser <b> Auto Correction </b></i><b> at work </b>


Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Breizh Blog