You will get PHP warnings on line 4 that $nonexistent doesn't exist, but
NO warnings on line 3 about $foo.
Stop repeating obvious stuff please, everyone on the list knows this.
PHP doesn't treat them the same, so how are we.
PHP itself isn't consistent, and
why we all asked for var
So I ask this:
get_declared_classes, class_exists
get_defined_functions, function_exist
get_defined_constants, defined
get_defined_vars, ???
classes, functions, constants are available everywhere, not just in the
current function. Including a foreign library adds classes, functions
and con
On Tue, Aug 19, 2003 at 05:32:41PM -0500, Shaun Thomas wrote:
> > > 2.) variable_exists can not be written in PHP.
> >
> > And it is not necessary, because get_defined_vars() exists.
>
> Which is just plain gross, but let's continue on...
How many local variables do you have? That array shouldn'
On Wed, 20 Aug 2003, Stefan Walk wrote:
> Won't work.
> [EMAIL PROTECTED]:~$ php -r 'var_dump(isset($var) || is_null($var));'
>
> Notice: Undefined variable: var in Command line code on line 1
> bool(true)
Ah yes. I was writing from the perspective of having set a value to
null beforehand. M
On Tue, Aug 19, 2003 at 04:38:03PM -0500, Shaun Thomas wrote:
> On Tue, 19 Aug 2003, fabrice wrote:
>
> > Empty($var) ? DoSomethingIfNotSetOrNull() : DoOther();
>
> That won't work. empty() will return true if the variable is set to a
> literal zero, false, blank, or null. So for your use, it's
On Tue, 19 Aug 2003, fabrice wrote:
> Empty($var) ? DoSomethingIfNotSetOrNull() : DoOther();
That won't work. empty() will return true if the variable is set to a
literal zero, false, blank, or null. So for your use, it's actually
worse than isset assuming your data can have zeros or blank val
AIL PROTECTED]
Objet : Re: [PHP-DEV] variable_exists() patch
On Fri, Aug 15, 2003 at 11:36:00AM +0200, Thies C. Arntzen wrote:
> On Fri, Aug 15, 2003 at 07:41:48AM +0800, Alan Knowles wrote:
> > I hit this a couple of months ago.. trying to implement NULL support
> > in dataobjects:
>
At 18:38 17/08/2003, Cristiano Duarte wrote:
"Robert Cummings" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> On Sat, 2003-08-16 at 18:28, Robert Cummings wrote:
> It is true that I could set the value to -1 or some such other hack, or
> that I could use array_keys() and then che
"Robert Cummings" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> On Sat, 2003-08-16 at 18:28, Robert Cummings wrote:
> It is true that I could set the value to -1 or some such other hack, or
> that I could use array_keys() and then check the values of the resulting
> array, but t
On Sat, 2003-08-16 at 18:28, Robert Cummings wrote:
>
> PHP then I think the option should be investigated. The current isset()
> function fails many developers from what I can see, and I know I've
> experienced this problem before, and so I think a more appropriate
Aaaah, I was just documenting s
Robert Cummings wrote:
> Understandably PHP is slower than say C :) Generally I don't think there
> is need for everything to be a native function, however, that said, when
> the speed gain and utility are great in comparison to doing it as pure
> PHP then I think the option should be investigate
Understandably PHP is slower than say C :) Generally I don't think there
is need for everything to be a native function, however, that said, when
the speed gain and utility are great in comparison to doing it as pure
PHP then I think the option should be investigated. The current isset()
function f
Oh, you meant the first output, nevermind. I /know/ unset() and setting
something null is not the same - as probably everyone on this list.
As to your "Is not the same" argument:
Doing something in PHP is of course slower as a language feature. But
that's normal. Do you want to have a native funct
On Sat, Aug 16, 2003 at 06:06:41PM -0400, Robert Cummings wrote:
> As you can see the entry is not null, it is completely missing.
You should use var_dump instead of print_r.
--
Regards,
Stefan Walk
<[EMAIL PROTECTED]>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, vis
Actually they are not the same, as this code illistrates:
$foo = array( 1, 2, 3, 4, 5 );
unset( $foo[1] );
foreach( $foo as $key => $value )
{
echo $foo.' -> '.$value."\n";
}
Output:
0 -> 1
2 -> 3
3 -> 4
4 -> 5
in contrast to:
$foo = array( 1, 2, 3, 4, 5 );
$foo[2] = null;
foreach( $foo
Yes, pretending that it is currently consistent is the problem I think.
By introducing the new function we solve the inconsistency. True there
are ways around this, such as get_defined_vars(). Interestingly, yet
another inconsistency is that get_defined_vars() also returns a variable
with a null va
On Sat, Aug 16, 2003 at 02:42:17PM -0700, Lars Torben Wilson wrote:
> But the change would make it more consistent, by recognizing that a
> variable with a NULL value is still defined. Pretending that $foo =
> null and unset($foo) are the same thing is quite inconsistent and
> confusing for many, w
On Sat, 2003-08-16 at 14:41, Zeev Suraski wrote:
> At 16:53 16/08/2003, Robert Cummings wrote:
> >So it seems to me that a null value does not define the non-existence of
> >a value, but is itself actually a value. And this as far as I am
> >concerned is quite valid.
>
> Ok, but it still doesn't c
At 16:53 16/08/2003, Robert Cummings wrote:
So it seems to me that a null value does not define the non-existence of
a value, but is itself actually a value. And this as far as I am
concerned is quite valid.
Ok, but it still doesn't change the fact that null is not a value :) The
fact we couldn't
On Sat, Aug 16, 2003 at 07:30:27PM +0300, Andrey Hristov wrote:
> However there is no $LOCALS in the local scope.
There is, sort of: http://www.php.net/get_defined_vars
--
Regards,
Stefan Walk
<[EMAIL PROTECTED]>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: htt
oooh,
here is easy sollution for global vars :
However there is no $LOCALS in the local scope.
Andrey
- Original Message -
From: "Cristiano Duarte" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, August 16, 2003 7:26 PM
Subject: Re: [PHP-DEV] v
"Robert Cummings" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> So it seems to me that a null value does not define the non-existence of
> a value, but is itself actually a value. And this as far as I am
> concerned is quite valid.
Shure. That's one more reason for variable_exis
"Stefan Walk" <[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]
> class Foo {
> function dump() {
> var_dump(array_key_exists('bar', (array)$this));
> }
> }
> $foo = new Foo;
> $foo->bar = null;
> $foo->dump();
> // => bool(true)
>
> It's not that hard to detect.
IMHO, array_k
On Thu, 2003-08-14 at 19:27, Zeev Suraski wrote:
> At 21:15 14/08/2003, walt boring wrote:
>
> The way PHP treats null value is identical to that of non existent values,
> which is precisely why isset() behaves the way that it does. I'm not sure
> what the logic is behind Ilia's alternatives, t
On Fri, Aug 15, 2003 at 11:36:00AM +0200, Thies C. Arntzen wrote:
> On Fri, Aug 15, 2003 at 07:41:48AM +0800, Alan Knowles wrote:
> > I hit this a couple of months ago.. trying to implement NULL
> > support in dataobjects:
> >
> > $do = DB_DataObject::factory('test');
> > $do->get(12);
> > $do->bi
> $do = DB_DataObject::factory('test');
> $do->birthday = null;
> $do->find();
>
> to do
> SELECT * FROM test WHERE birthday IS NULL;
>
> but since there was no effective way to detect null, as apposed to
> unset.. I had to give up... - If this could be solved by
> variable_exists() - even thoug
<[EMAIL PROTECTED]> escreveu na mensagem
news:[EMAIL PROTECTED]>
> You can avoid the notice by doing if(isset($var) && !is_null($var)) { }
>
> We can't have a function for every piece of code.
>
IMHO, a function to test if a variable exists or not is not "every piece of
code". See what is necessary
At 12:36 15/08/2003, Thies C. Arntzen wrote:
On Fri, Aug 15, 2003 at 07:41:48AM +0800, Alan Knowles wrote:
> I hit this a couple of months ago.. trying to implement NULL
> support in dataobjects:
>
> $do = DB_DataObject::factory('test');
> $do->get(12);
> $do->birthday = null;
> $do->update();
>
>
On Fri, Aug 15, 2003 at 07:41:48AM +0800, Alan Knowles wrote:
> I hit this a couple of months ago.. trying to implement NULL
> support in dataobjects:
>
> $do = DB_DataObject::factory('test');
> $do->get(12);
> $do->birthday = null;
> $do->update();
>
> was supposed to generate
> SELECT * FROM te
"Walt Boring" <[EMAIL PROTECTED]> a écrit dans le message de
news:[EMAIL PROTECTED]
> Stefan Walk wrote:
>
> >On Thu, Aug 14, 2003 at 11:15:51AM -0700, walt boring wrote:
> >
> >
> >>I for one would like to see something like variable_exists(), as I am
> >>very annoyed with
> >>the logic of isset(
I hit this a couple of months ago.. trying to implement NULL support in
dataobjects:
$do = DB_DataObject::factory('test');
$do->get(12);
$do->birthday = null;
$do->update();
was supposed to generate
SELECT * FROM test WHERE id=12;
UPDATE test SET birthday=NULL where id = 12;
or
$do = DB_DataObje
On Thu, 2003-08-14 at 16:27, Zeev Suraski wrote:
> At 21:15 14/08/2003, walt boring wrote:
> >Ilia Alshanetsky wrote:
> >
> >>Do we really need this function? I see 2 ways of 'implementing' this
> >>functionality in PHP without having to add another function. For example:
> >>(isset($var) || is_nu
At 21:15 14/08/2003, walt boring wrote:
Ilia Alshanetsky wrote:
Do we really need this function? I see 2 ways of 'implementing' this
functionality in PHP without having to add another function. For example:
(isset($var) || is_null($var)) or gettype($var).
Ilia
I for one would like to see someth
On Thu, 2003-08-14 at 14:01, Stefan Walk wrote:
> On Thu, Aug 14, 2003 at 12:00:26PM -0700, walt boring wrote:
> > It can happen quite easily. I always develop with full warnings/errors on.
>
> So do I.
>
> > So if for example a var isn't set for whatever reason, then trying to
> > access the
On Thu, Aug 14, 2003 at 12:00:26PM -0700, walt boring wrote:
> It can happen quite easily. I always develop with full warnings/errors on.
So do I.
> So if for example a var isn't set for whatever reason, then trying to
> access the
> variable will throw a php Notice. variable_exists() would p
"Ilia Alshanetsky" <[EMAIL PROTECTED]> a écrit dans le message de
news:[EMAIL PROTECTED]
> Do we really need this function? I see 2 ways of 'implementing' this
> functionality in PHP without having to add another function. For example:
> (isset($var) || is_null($var)) or gettype($var).
Sure its r
Do we really need this function? I see 2 ways of 'implementing' this
functionality in PHP without having to add another function. For example:
(isset($var) || is_null($var)) or gettype($var).
Ilia
On August 13, 2003 06:25 pm, Lars Torben Wilson wrote:
> Hi out there,
>
> A few weeks ago I submit
Hi out there,
A few weeks ago I submitted a patch in the bug db for a
variable_exists() construct, which parallels the function_exists()
one but for variables. In short, it returns TRUE if a variable
exists, regardless of its value. In other words, it's an isset()
which doesn't care if the varia
Utility is in the eye of the beholder... you may not see where it would
be useful, but I'd argue that many others do.
Cheers,
Rob.
On Thu, 2003-08-14 at 15:42, Ilia Alshanetsky wrote:
> Correct, it appears my php work around may not work as a undefined variable
> would gain a NULL value as soon
Correct, it appears my php work around may not work as a undefined variable
would gain a NULL value as soon as it's used, making is_null() always return
true. That said, I still do not see a situation where such a function would
be useful.
Ilia
--
PHP Internals - PHP Runtime Development Mai
On Thu, 2003-08-14 at 08:45, Ilia Alshanetsky wrote:
> Do we really need this function? I see 2 ways of 'implementing' this
> functionality in PHP without having to add another function. For example:
> (isset($var) || is_null($var)) or gettype($var).
>
> Ilia
Those ideas don't do the same thing,
Stefan Walk wrote:
On Thu, Aug 14, 2003 at 11:15:51AM -0700, walt boring wrote:
I for one would like to see something like variable_exists(), as I am
very annoyed with
the logic of isset() returning false if the variable exists and has a
value of null.
[snip]
I for one would much ra
On Thu, Aug 14, 2003 at 11:15:51AM -0700, walt boring wrote:
> I for one would like to see something like variable_exists(), as I am
> very annoyed with
> the logic of isset() returning false if the variable exists and has a
> value of null.
[snip]
> I for one would much rather do
> if ( vari
Ilia Alshanetsky wrote:
Do we really need this function? I see 2 ways of 'implementing' this
functionality in PHP without having to add another function. For example:
(isset($var) || is_null($var)) or gettype($var).
Ilia
I for one would like to see something like variable_exists(), as I am
v
44 matches
Mail list logo