MarkupDirectiveFunctions-Talk
This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.
Is this compatible with PHP 8?
In the documentation section "Usage" item 3 for '$args' it says:
$args: an array with the parsed arguments within the start directive (see documentation for ParseArgs).
in the above example, $args['arg1'] will be 'val1', and $args['arg2'] will be 'val 2'.
I did:
page code:
(:showcode "http://localhost/z/info.txt":)
config code:
$MarkupDirectiveFunctions['showcode'] = 'showcode';
function showcode($pagename, $directive, $args, $content = '') {
return Keep(nl2br(print_r($args)));
}
and my output is:
Array
(
[#] => Array
(
[0] =>
[1] => http://localhost/z/info.txt
)
[] => Array
(
[0] => http://localhost/z/info.txt
)
)
--gnuzoo
This is the expected behavior of ParseArgs, arguments without names are in the $args[''] array and are positional. Try a named argument like "url=http://localhost/z/info.txt". You can ignore the arguments you don't need. See also Test.ParseArgs --Petko
This should be simplified, I don't like some aspects, but as people are using it I'll likely add a new/separate way to do it. --Petko
Talk page for the MarkupDirectiveFunctions recipe (users).