Doc #79598 [NEW]: update string function docs please
| From: | danwassonpgh at hotmail dot com | Date: | Thu, 14 May 2020 17:35:56 +0000 |
| Subject: | Doc #79598 [NEW]: update string function docs please | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-17576@lists.php.net to get a copy of this message | ||
From: danwassonpgh at hotmail dot com
Operating system:
PHP version: 7.4.6
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:update string function docs please
Description:
------------
Could the documentation on php.net under 'PHP Manual > Function
Reference > Text Processing Strings > String Functions' mention how some
of the functions (substr, strpos), handle html special chars? The
example in the "Test script" shows the confusion I encountered before
learning by coding and running the "Test script". Thank you
Test script:
---------------
$stringA = 'Lorem ipsum, <x> sit amet, consectetur </x> adipiscing';
$substrA1 = substr($stringA, 0, 24);
$substrA2 = substr(htmlspecialchars($stringA), 0, 24);
$stringB = 'Lorem ipsum, xxx sit amet, consectetur xxxx adipiscing';
$substrB1 = substr($stringB, 0, 24);
$substrB2 = substr(htmlspecialchars($stringB), 0, 24);
echo '<pre>';
echo '<br>
..............................|----|----1----|----2----|----3----|----4----|----5----|';
echo '<br> $stringA as htmlspecialchars |' . htmlspecialchars($stringA)
. '|';
echo '<br> $substrA1 as raw |' . $substrA1 . '|';
echo '<br> $substrA1 as htmlspecialchars |' .
htmlspecialchars($substrA1) . '|';
echo '<br> $substrA2 as raw |' . $substrA2 . '|';
echo '<br> $substrA2 as htmlspecialchars |' .
htmlspecialchars($substrA2) . '|';
echo '<br> $stringB as htmlspecialchars |' . htmlspecialchars($stringB)
. '|';
echo '<br> $substrB1 as raw |' . $substrB1 . '|';
echo '<br> $substrB2 as htmlspecialchars |' . $substrB2 . '|';
echo '<br></pre>';
Actual result:
--------------
..............................|----|----1----|----2----|----3----|----4----|----5----|
$stringA as htmlspecialchars |Lorem ipsum, <x> sit amet, consectetur
</x> adipiscing|
$substrA1 as raw |Lorem ipsum, sit ame|
$substrA1 as htmlspecialchars |Lorem ipsum, <x> sit ame|
$substrA2 as raw |Lorem ipsum, <x> s|
$substrA2 as htmlspecialchars |Lorem ipsum, <x> s|
$stringB as htmlspecialchars |Lorem ipsum, xxx sit amet, consectetur
xxxx adipiscing|
$substrB1 as raw |Lorem ipsum, xxx sit ame|
$substrB2 as htmlspecialchars |Lorem ipsum, xxx sit ame|
--
Edit bug report at https://bugs.php.net/bug.php?id=79598&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79598&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79598&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79598&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79598&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79598&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79598&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79598&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79598&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79598&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79598&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79598&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79598&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79598&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79598&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79598&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79598&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79598&r=mysqlcfg