WordPress-Coding-Standards/WordPress/Docs/PHP/PregQuoteDelimiterStandard.xml
Xristopher Anderton fae2dc0bae PHP/PregQuoteDelimiter: add XML documentation
Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
2025-12-24 07:53:51 -03:00

35 lines
1 KiB
XML

<?xml version="1.0"?>
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
title="Preg Quote Delimiter"
>
<standard>
<![CDATA[
Passing the $delimiter parameter to `preg_quote()` is strongly recommended to ensure the regular expression delimiter is properly escaped if it occurs in the input string.
]]>
</standard>
<code_comparison>
<code title="Valid: The delimiter parameter is passed.">
<![CDATA[
// $input = 'my #1 fan!';
$quoted_input = preg_quote( $input, <em>'#'</em> );
preg_match(
<em>'#^' . $quoted_input . '#i'</em>,
$post_content,
$matches
);
]]>
</code>
<code title="Invalid: The delimiter parameter is missing.">
<![CDATA[
// $input = 'my #1 fan!';
$quoted_input = preg_quote( $input<em></em> );
preg_match(
<em>'#^' . $quoted_input . '#i'</em>,
$post_content,
$matches
);
]]>
</code>
</code_comparison>
</documentation>