On Fri, 16 Apr 2004, Andi Gutmans wrote:
> At 02:21 PM 4/15/2004 -0400, Sean Coates wrote:
> >Andi Gutmans wrote:
> >>It could be implemented but I don't see the big advantage over $bar ? 0 :
> >>$base
> >>It's one character...
> >>oes to GCC and its C extension).
> $bar ? : $baz;
>
Hello Jason,
here is your operator patch:
http://marcus-boerger.de/php/ext/ze2/ze2-ifsetor-20040416.diff.txt
currently it uses the following syntax:
$var $: $defaul
which would equal
isset($var) ? $var : $default
Notice that at the moment the operator is '$:' and not '?:'. This is
because i h
Hello,
Let me make an attempt to clarify what I originally requested.
--
A function/construct named setor() modeled after isset(), which takes 2
parameters:
parameter 1, the variable in question
parameter 2, the default value
if(isset($parameter1))
return $parameter1;
else
return $p
At 02:21 PM 4/15/2004 -0400, Sean Coates wrote:
Andi Gutmans wrote:
It could be implemented but I don't see the big advantage over $bar ? 0 :
$base
It's one character...
oes to GCC and its C extension).
$bar ? : $baz;
If $bar evaluates to true, the expression evaluates to $bar
or to 0,
Sean Coates wrote:
Jason Garber wrote:
function setor(&$param, $default)
{
return (isset($param) ? $param : $default);
}
I tested it on 4.3.4 and 5.0 RC1, and it worked. Is passing an
undefined variable as a reference parameter a legal thing to do in PHP?
That bring up an interesting point
Jason Garber wrote:
function setor(&$param, $default)
{
return (isset($param) ? $param : $default);
}
I tested it on 4.3.4 and 5.0 RC1, and it worked. Is passing an
undefined variable as a reference parameter a legal thing to do in PHP?
That bring up an interesting point:
error_reporting(E_A
Hello Derick,
Thursday, April 15, 2004, 10:07:01 PM, you wrote:
> On Thu, 15 Apr 2004, Jason Garber wrote:
>> I see. I was basing the spec on the functionality of isset() which does
>> not (obviously) throw an E_NOTICE when you pass an undefined variable to
>> it. However, do you see any reaso
+1 for the GCC style syntax.
--Wez.
- Original Message -
From: "Hartmut Holzgraefe" <[EMAIL PROTECTED]>
To: "Sascha Schumann" <[EMAIL PROTECTED]>
Cc: "Ilia Alshanetsky" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, A
You can avoid the E_NOTICE using a reference, but it can have undesired
side effects. For example, if you pass $x[5] by reference (whether to
an internal function or a user defined function), $x[5] will be
"created" and set to NULL. To avoid this side-effect, don't use the
reference and instead
I wrote this (I underlined the relevant parts for you):
> >You'll need something more clever, because
> >an undefined key 'CUST_ID' in $_POST['CUST_ID'] will strill throw a
Consider this:
---
error_reporting(E_ALL);
function setor(&$param, $default)
{
On Thu, 15 Apr 2004, Jason Garber wrote:
> I see. I was basing the spec on the functionality of isset() which does
> not (obviously) throw an E_NOTICE when you pass an undefined variable to
> it. However, do you see any reason that this would not reliably work?
I wrote this (I underlined the re
Hi Derick,
I see. I was basing the spec on the functionality of isset() which does
not (obviously) throw an E_NOTICE when you pass an undefined variable to
it. However, do you see any reason that this would not reliably work?
function setor(&$param, $default)
{
return (isset($param) ? $pa
On Thu, 15 Apr 2004, Jason Garber wrote:
> $_POST['CUST_ID'] = (int) isset_or_default($_POST['CUST_ID'], 0);
>
> I agree that it would be helpful not to evaluate the second parameter
> unless needed, which is why I originally proposed a language construct.
You'll need something more clever, becau
Sascha Schumann wrote:
That is basically the same idea once proposed as extending
the ternary operator (credit goes to GCC and its C extension).
$bar ? : $baz;
yes, that looks like the way it should look like,
and the danger of newbees abusing it would be way lower
than with a function
The best functionality would be for it to return the value, not re-assign
it. Many of the things being talked about would modify the sent parameter,
rather than return selected value.
For instance (using the isset_or_default()) call:
$nCustID = (int) isset_or_default($_POST['CUST_ID'], 0);
Th
On April 15, 2004 02:15 pm, Andi Gutmans wrote:
> It could be implemented but I don't see the big advantage over $bar ? 0 :
> $base It's one character...
Well, currently to check the value and assign the default you need to do the
following:
$_GET['foo'] = isset($_GET['foo']) ? (int) $_GET['foo'
Andi Gutmans wrote:
It could be implemented but I don't see the big advantage over $bar ? 0
: $base
It's one character...
oes to GCC and its C extension).
$bar ? : $baz;
If $bar evaluates to true, the expression evaluates to $bar
or to 0, respectively.
I think we're unclear on this.
It could be implemented but I don't see the big advantage over $bar ? 0 : $base
It's one character...
At 02:09 PM 4/15/2004 -0400, Sean Coates wrote:
Is there a good reason to NOT implement this?
If not, I'm +1 on that (if I carry ANY weight at all (-: )
BC isn't an issue, and it would be a very us
+1
-Original Message-
From: Sean Coates [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 12:10 PM
To: Sascha Schumann
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DEV] Construct Request
Is there a good reason to NOT implement this?
If not, I'm +1 on that (if I carry ANY weight a
Is there a good reason to NOT implement this?
If not, I'm +1 on that (if I carry ANY weight at all (-: )
BC isn't an issue, and it would be a very useful feature, IMHO..
S
Sascha Schumann wrote:
That is basically the same idea once proposed as extending
the ternary operator (credit goes t
That is basically the same idea once proposed as extending
the ternary operator (credit goes to GCC and its C extension).
$bar ? : $baz;
If $bar evaluates to true, the expression evaluates to $bar
or to 0, respectively.
- Sascha
--
PHP Internals - PHP Runtime Developmen
I am not sure what would be the best name for such an engine construct or a
function, but the idea itself is good (IMHO). It would certainly make it
easier to write safer notice free code.
Ilia
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/un
Hello Internals team,
Thank you for taking a moment to evaluate a serious request by a serious
php developer that is responsible for a development company of 15 employees.
In order to keep our code as clean and error free as possible, we opt to
develop in the E_ALL error mode, and register_globals
23 matches
Mail list logo