No cache version.
Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.
bbcode_set_arg_parser
(PECL bbcode >= 0.10.2)
bbcode_set_arg_parser — Attach another parser in order to use another rule set for argument parsing
Description
$bbcode_container
, resource $bbcode_arg_parser
) : boolAttaches another parser to the bbcode_container. This parser is used only when arguments must be parsed. If this function is not used, the default argument parser is the parser itself.
Parameters
-
bbcode_container
-
BBCode_Container resource, returned by bbcode_create().
-
bbcode_arg_parser
-
BBCode_Container resource, returned by bbcode_create(). It will be used only for parsed arguments
Examples
Example #1 bbcode_set_arg_parser() usage example
<?php
/*
* Generating bbcode ruleset for main parser
*/
$arrayBBCode=array(
'quote'=> array('type'=>BBCODE_TYPE_ARG,
'open_tag'=>'<quote><h4>Source: {PARAM}</h4>',
'close_tag'=>'</quote>',
'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY|BBCODE_FLAGS_ARG_PARSING),
'b'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<b>', 'close_tag'=>'</b>',
'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY),
'u'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<u>', 'close_tag'=>'</u>',
'flags'=>BBCODE_FLAGS_SMILEYS_OFF | BBCODE_FLAGS_REMOVE_IF_EMPTY | BBCODE_FLAGS_SMILEYS_OFF),
'i'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<i>', 'close_tag'=>'</i>',
'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY),
);
/*
* Generating bbcode ruleset for argument parser
*/
$arrayBBCode_arg=array(
'b'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<b class="sub">', 'close_tag'=>'</b>',
'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY),
'u'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<u>', 'close_tag'=>'</u>',
'flags'=>BBCODE_FLAGS_SMILEYS_OFF | BBCODE_FLAGS_REMOVE_IF_EMPTY | BBCODE_FLAGS_SMILEYS_OFF),
'i'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<i>', 'close_tag'=>'</i>',
'flags'=>BBCODE_FLAGS_REMOVE_IF_EMPTY),
);
/*
* Text we are going to parse
*/
$text=<<<EOF
[quote="[b]Test[/b]"]
Foo :)
[/quote]
[b]Bar example :)[/b] :)
EOF;
/*
* Init the two parsers
*/
$BBHandler=bbcode_create($arrayBBCode);
$BBArgHandler=bbcode_create($arrayBBCode_arg);
/*
* Setting Flags on the parsers
*/
bbcode_set_flags($BBHandler,
BBCODE_CORRECT_REOPEN_TAGS|BBCODE_DEFAULT_SMILEYS_ON|BBCODE_ARG_DOUBLE_QUOTE|
BBCODE_ARG_SINGLE_QUOTE|BBCODE_ARG_HTML_QUOTE,BBCODE_SET_FLAGS_SET);
bbcode_set_flags($BBArgHandler,
BBCODE_CORRECT_REOPEN_TAGS|BBCODE_DEFAULT_SMILEYS_ON|BBCODE_ARG_DOUBLE_QUOTE|
BBCODE_ARG_SINGLE_QUOTE|BBCODE_ARG_HTML_QUOTE,BBCODE_SET_FLAGS_SET);
/*
* Setting $BBArgHandler as the BBHandler argument parser
*/
bbcode_set_arg_parser($BBHandler,$BBArgHandler);
/*
* Adding Smileys handling rules to Main parser
*/
bbcode_add_smiley($BBHandler, ":)", "<img src=\"smiley.gif\" alt=\":)\" />");
/*
* Use the main parser to parse text
*/
echo bbcode_parse($BBHandler,$text);
?>
The above example will output:
<quote><h4>Source: <b class="sub">Test</b></h4> Foo <img src="smiley.gif" alt=":)" /> </quote> <b>Bar example :)</b> <img src="smiley.gif" alt=":)" />
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-bbcode-set-arg-parser.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.