Doc #79598 [Opn->Fbk]: update string function docs please

From: Date: Thu, 14 May 2020 18:06:35 +0000
Subject: Doc #79598 [Opn->Fbk]: update string function docs please
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17577@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: requinix@php.net Reported by: danwassonpgh at hotmail dot com Summary: update string function docs please -Status: Open +Status: Feedback Type: Documentation Problem -Package: Documentation problem +Package: Strings related PHP Version: 7.4.6 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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, &lt;x&gt; 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

« previous php.doc.bugs (#17577) next »