Re: Adding a more logical string slicing function to PHP
| From: | Rasmus Lerdorf | Date: | Thu, 31 Mar 2011 18:10:08 +0000 |
| Subject: | Re: Adding a more logical string slicing function to PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51778@lists.php.net to get a copy of this message | ||
On 03/31/2011 10:58 AM, Martin Scotta wrote:
> I think it's time to stop thinking in terms of "functions" and move
> forward to "abstractions"
>
> $s1 = 'string';
> $s1->contains($s2);
>
> $s1->indexOf($s2) === strpos($s1, $s2);
>
> Why can't the strings be exposed as pseudo-objects ? users can choose to
> use them as a regular strings or by calling methods on it.
This is actually something I have been toying with a bit. Adding the
ability to call methods on both strings and arrays. I still don't like
the idea of making them real objects as the overhead and the amount of
code that would need to be changed in the core and in every extension is
daunting. Anybody out there have a patch along these lines?
-Rasmus