Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-03-31 Thread Ben Schmidt
On 1/04/11 3:29 AM, David Coallier wrote: Hey there, I've been working on a little patch that will allow variables ($1) in a short-ternary operation to go through an implicit isset (zend_do_isset_or_isempty) check so that the average use-case for the short-ternary operator doesn't yield in a not

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Dan Birken
On a somewhat related note (and going back a little to my original patch), languages like python and ruby allow slicing on array/string objects with $string_or_array[start:end] syntax. I think this would be really useful syntax in PHP as well (and would of course make the initial patch I submitted

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Rasmus Lerdorf
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

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Martin Scotta
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 o

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Philip Olson
On Mar 31, 2011, at 9:55 AM, Sebastian Bergmann wrote: > Am 31.03.2011 17:52, schrieb Rasmus Lerdorf: >> Argh! Everyone should be forced to learn a bit of C. Like many PHP >> functions, the name and argument order is right out of libc. If you type >> "man strstr" at your (non-Windows) prompt you

[PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-03-31 Thread David Coallier
Hey there, I've been working on a little patch that will allow variables ($1) in a short-ternary operation to go through an implicit isset (zend_do_isset_or_isempty) check so that the average use-case for the short-ternary operator doesn't yield in a notice whenever the first variable of the expre

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Peter Cowburn
On 31 March 2011 16:43, Brian Moon wrote: >>> How would str_contains() be different from strstr()? >>> >>> >> They differ in the return type > > $instr = (bool)strstr($string1, $string2); > > done. No need for a new function. God forbid anyone use (bool)strstr("something0", "0") ! > > Brian. > >

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Sebastian Bergmann
Am 31.03.2011 17:52, schrieb Rasmus Lerdorf: > Argh! Everyone should be forced to learn a bit of C. Like many PHP > functions, the name and argument order is right out of libc. If you type > "man strstr" at your (non-Windows) prompt you get a nice little > description of what it does. And if you

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Rasmus Lerdorf
On 03/31/2011 08:45 AM, Philip Olson wrote: > - Intuitive name Argh! Everyone should be forced to learn a bit of C. Like many PHP functions, the name and argument order is right out of libc. If you type "man strstr" at your (non-Windows) prompt you get a nice little description of what it does.

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Philip Olson
On Mar 31, 2011, at 9:43 AM, Brian Moon wrote: >>> How would str_contains() be different from strstr()? >>> >>> >> They differ in the return type > > $instr = (bool)strstr($string1, $string2); > > done. No need for a new function. Well, to be clearer: bool str_contains( haystack, needle [,

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Martin Jansen
On 31.03.11 17:05, Rasmus Lerdorf wrote: > On 03/31/2011 07:41 AM, Philip Olson wrote: >> On Mar 30, 2011, at 1:42 PM, Martin Jansen wrote: >>> I recently got around to merge them into a largely unfinished extension >>> so they are archived somewhere safe: https://github.com/mj/php-ext-str >> >> I

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Brian Moon
How would str_contains() be different from strstr()? They differ in the return type $instr = (bool)strstr($string1, $string2); done. No need for a new function. Brian. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Martin Scotta
Martin Scotta On Thu, Mar 31, 2011 at 12:05 PM, Rasmus Lerdorf wrote: > On 03/31/2011 07:41 AM, Philip Olson wrote: > > > > On Mar 30, 2011, at 1:42 PM, Martin Jansen wrote: > > > >> On 30.03.11 21:36, Dan Birken wrote: > >>> As for adding other string functions, I agree, I think there are a l

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Rasmus Lerdorf
On 03/31/2011 07:41 AM, Philip Olson wrote: > > On Mar 30, 2011, at 1:42 PM, Martin Jansen wrote: > >> On 30.03.11 21:36, Dan Birken wrote: >>> As for adding other string functions, I agree, I think there are a lot of >>> them that would be great to add. starts_with & ends_with for sure. >> >> B

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Ferenc Kovacs
On Thu, Mar 31, 2011 at 4:49 PM, Martin Jansen wrote: > On 31.03.11 16:41, Philip Olson wrote: > > On Mar 30, 2011, at 1:42 PM, Martin Jansen wrote: > >> Both str_startswith and str_endswith have been suggested in the past: > >> > >> http://marc.info/?t=12164723011&r=1&w=2 > >> > >> I recentl

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Martin Jansen
On 31.03.11 16:41, Philip Olson wrote: > On Mar 30, 2011, at 1:42 PM, Martin Jansen wrote: >> Both str_startswith and str_endswith have been suggested in the past: >> >> http://marc.info/?t=12164723011&r=1&w=2 >> >> I recently got around to merge them into a largely unfinished extension >> so t

Re: [PHP-DEV] Adding a more logical string slicing function to PHP

2011-03-31 Thread Philip Olson
On Mar 30, 2011, at 1:42 PM, Martin Jansen wrote: > On 30.03.11 21:36, Dan Birken wrote: >> As for adding other string functions, I agree, I think there are a lot of >> them that would be great to add. starts_with & ends_with for sure. > > Both str_startswith and str_endswith have been suggeste

[PHP-DEV] SVN Account Request: rlms

2011-03-31 Thread Pål-Kristian Hamre
We need access to this repository to commit changes to the infrastructure: https://svn.php.net/repository/systems/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Displaying a loggable error during PHP_MINIT_FUNCTION and suppressing the loading of the module.

2011-03-31 Thread Richard Quadling
Hi. I can use return FAILURE during PHP_MINIT_FUNCTION to stop a module from loading and the appropriate message is displayed ... PHP Warning: PHP Startup: Unable to load dynamic library 'xx' - The specified module could not be found. in Unknown on line 0 I want to restrict the module to o

Re: [PHP-DEV] Determine the name of the PHP SAPI module.

2011-03-31 Thread Richard Quadling
On 31 March 2011 10:31, Rasmus Lerdorf wrote: > #include "SAPI.h" > > and then you will have the name in the global sapi_module struct: > > sapi_module.name > > -Rasmus > > On 03/31/2011 02:24 AM, Richard Quadling wrote: >> Hi. >> >> From a CLI/CGI perspective, the following code returns the full

Re: [PHP-DEV] Determine the name of the PHP SAPI module.

2011-03-31 Thread Rasmus Lerdorf
#include "SAPI.h" and then you will have the name in the global sapi_module struct: sapi_module.name -Rasmus On 03/31/2011 02:24 AM, Richard Quadling wrote: > Hi. > > From a CLI/CGI perspective, the following code returns the full path > of the php.exe file. > > DWORD len; >

[PHP-DEV] Determine the name of the PHP SAPI module.

2011-03-31 Thread Richard Quadling
Hi. >From a CLI/CGI perspective, the following code returns the full path of the php.exe file. DWORD len; char buf[MAX_PATH]; len = GetModuleFileName(NULL, buf, sizeof(buf)); buf[len] = '\0'; If PHP is loaded as a module, how do y