Doc #79598 [Fbk->NoF]: update string function docs please
| From: | php-bugs at lists dot php dot net | Date: | Sun, 24 May 2020 04:22:08 +0000 |
| Subject: | Doc #79598 [Fbk->NoF]: update string function docs please | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17611@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79598&edit=1
ID: 79598
Updated by: php-bugs@lists.php.net
Reported by: danwassonpgh at hotmail dot com
Summary: update string function docs please
-Status: Feedback
+Status: No Feedback
Type: Documentation Problem
Package: Strings related
PHP Version: 7.4.6
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2020-05-14 18:06:35] requinix@php.net
Not sure what you're talking about. substr and most other string functions *do not* handle HTML
characters. They don't care.
It seems like the issue you're dealing with is that you're viewing the output from PHP as
it's being rendered by your browser. Emphasis on "rendered". Oftentimes you need to
be doing a View Source to see the raw output instead.
------------------------------------------------------------------------
[2020-05-14 17:35:56] danwassonpgh at hotmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=79598&edit=1