RE: [PHP] Odd Code Error.

2004-01-21 Thread Jay Blanchard
[snip] Interesting. I wouldn't have expected that. However, that is how it should work. Check out table K-2 on this page: http://us4.php.net/manual/en/types.comparisons.php '==' is a loose comparison. You can use '===' instead which will give you the results you are looking for. if ($EA

RE: [PHP] Odd Code Error.

2004-01-21 Thread Ford, Mike [LSS]
On 21 January 2004 04:01, Luke contributed these pearls of wisdom: ok, i read the section, but even so if $a == $b and $a == $c then $b should be equal to $c No, not necessarily! but php is saying otherwise? Yes. this sounds confusing i want to try n get my head round it a string

Re: [PHP] Odd Code Error.

2004-01-21 Thread Jonathan Pitcher
Thanks. It makes sense now. Now I have one more question. Not to confuse the issue more. :) $EA = 0 if ($EA == NFH) // would work because the string is converted to an integer and then compared correct ? And by using === I tell it to compare type and value ? If that is true would 0 == 0?

Re: [PHP] Odd Code Error.

2004-01-21 Thread Robert Cummings
On Wed, 2004-01-21 at 15:38, Jonathan Pitcher wrote: Thanks. It makes sense now. Now I have one more question. Not to confuse the issue more. :) $EA = 0 if ($EA == NFH) // would work because the string is converted to an integer and then compared correct ? And by using === I tell

Re: [PHP] Odd Code Error.

2004-01-21 Thread Chris W
Luke wrote: yeah its strange, $test is equal to $test2, $test is equal to $test3 but $test2 is not equal to $test3, $test = string; $test2 = true; $test3 = 0; if($test == $test2){ echo hi; } somone tell me im wrong please? else thats seriously weird I'm sure many will disagree with me on this

Re: [PHP] Odd Code Error.

2004-01-21 Thread Martin Hjort Eriksen
I agree with Chris... In contrast you can also see a common problem in many of the downloadable scripts from different collections on the net, like hotscripts.com, where the programmers start building control structures whitout having the different variables they use set. For instance

Re: [PHP] Odd Code Error.

2004-01-21 Thread Robert Cummings
Hmmm, I don't think other programmer's sloppy coding practices are a good argument for having to declare variables or against loose typing. There are crappy coders in whatever language you use. The good coders will do the right thing. If you are concerned about scripts on hotscripts.com where the

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
I agree with Chris... In contrast you can also see a common problem in many of the downloadable scripts from different collections on the net, like hotscripts.com, where the programmers start building control structures whitout having the different variables they use set. For instance

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
So do you recommend using isset($name) instead of ($name) ? And what are you meaning by setting the var as in var $name ? i usually set them in classes but how about in normal scripts and functions ? Hmm i was checking out a pear class, what about the variables within a function ? like

Re: [PHP] Odd Code Error.

2004-01-21 Thread Martin Hjort Eriksen
[EMAIL PROTECTED] wrote: So do you recommend using isset($name) instead of ($name) ? And what are you meaning by setting the var as in var $name ? i usually set them in classes but how about in normal scripts and functions ? Yes, if you want to examine if a variable is set or not, then you

Re: [PHP] Odd Code Error.

2004-01-21 Thread John W. Holmes
[EMAIL PROTECTED] wrote: Hmm i was checking out a pear class, what about the variables within a function ? like function foo($name) { if ($name) { } } or foo($name) { if (isset($name)) { } } it uses isset on variables coming outside the function Those examples don't make much sense. Without

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
Yes, if you want to examine if a variable is set or not, then you should use isset(). Ok i'll start using it Exactly how a variable should be set, well it could be for instance var $age:int; Where on the php site does it tell you to set it like that ? I've never seent that before ?

Re: [PHP] Odd Code Error.

2004-01-21 Thread Martin Hjort Eriksen
[EMAIL PROTECTED] wrote: Exactly how a variable should be set, well it could be for instance var $age:int; Where on the php site does it tell you to set it like that ? I've never seent that before ? It is also because you cannot do it... :) It was an idea on how it could be done,

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
[EMAIL PROTECTED] wrote: Hmm i was checking out a pear class, what about the variables within a function ? like function foo($name) { if ($name) { } } or foo($name) { if (isset($name)) { } } it uses isset on variables coming outside the function Those examples don't make

Re: [PHP] Odd Code Error.

2004-01-21 Thread Martin Hjort Eriksen
[EMAIL PROTECTED] wrote: I dont understand, i assume that would check if name was set, i also set functions like function foo($name,$bar = null) { } so therefore bar doesnt need to be inputted, seeing as i set it to null would i check if $bar===true ? or just isset($bar ) ? when you have set

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
And $bar === true will only become true, if $bar is true, look at table K-3 here http://www.php.net/manual/en/types.comparisons.php Ok i tested it out function foo($bar = null) { if (isset($bar)) die(yes); } foo(test); will die where foo(); wont -- PHP General Mailing List

Re: [PHP] Odd Code Error.

2004-01-21 Thread Chris W
Robert Cummings wrote: Hmmm, I don't think other programmer's sloppy coding practices are a good argument for having to declare variables or against loose typing. There are crappy coders in whatever language you use. The good coders will do the right thing. If you are concerned about scripts on

Re: [PHP] Odd Code Error.

2004-01-21 Thread John Nichel
Chris W wrote: snip I challenge anyone to find a disadvantage in forcing decelerations of variables and functions, other than having to type more. Forcing declaration will create more list traffic... I'm getting the error 'Variable $foo not declared on line 321', somebody fix my code... And

Re: [PHP] Odd Code Error.

2004-01-21 Thread Robert Cummings
On Wed, 2004-01-21 at 20:19, Chris W wrote: Robert Cummings wrote: Hmmm, I don't think other programmer's sloppy coding practices are a good argument for having to declare variables or against loose typing. There are crappy coders in whatever language you use. The good coders will do the

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
On Wed, 2004-01-21 at 20:19, Chris W wrote: Robert Cummings wrote: May i ask how you handle your error handling Robert ? I'm considering moving my class error handling to pear but then it'll need a custom class or function anyway to handle the errors in different ways for different applications

Re: [PHP] Odd Code Error.

2004-01-21 Thread John W. Holmes
Chris W wrote: $Key = xyz; lots more code here. if($key == xyz){ Notice: Undefined variable: key in \path\to\test.php on line X do this stuff; } lots more code here; If the language forces variable deceleration you simply get an error variable $key not defined on line x then there is no

Re: [PHP] Odd Code Error.

2004-01-21 Thread Robert Cummings
On Wed, 2004-01-21 at 21:37, [EMAIL PROTECTED] wrote: On Wed, 2004-01-21 at 20:19, Chris W wrote: Robert Cummings wrote: May i ask how you handle your error handling Robert ? I'm considering moving my class error handling to pear but then it'll need a custom class or function anyway to

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
Ok i found something very interesting , i have a session var setup to check for a groupID which is an integer, if ($_SESSION['groupID']==1) { this was working, then when i changed it to if ($_SESSION['groupID']===1) { per recomendation, it does not now ! i was going through my code and changing

Re: [PHP] Odd Code Error.

2004-01-21 Thread daniel
Ok i found something very interesting , i have a session var setup to check for a groupID which is an integer, if ($_SESSION['groupID']==1) { this was working, then when i changed it to if ($_SESSION['groupID']===1) { per recomendation, it does not now ! i was going through my code and

Re: [PHP] Odd Code Error.

2004-01-21 Thread John Nichel
[EMAIL PROTECTED] wrote: Ok i found something very interesting , i have a session var setup to check for a groupID which is an integer, if ($_SESSION['groupID']==1) { this was working, then when i changed it to if ($_SESSION['groupID']===1) { per recomendation, it does not now ! i was going

RE: [PHP] Odd Code Error.

2004-01-21 Thread Martin Towell
[EMAIL PROTECTED] wrote: Ok i found something very interesting , i have a session var setup to check for a groupID which is an integer, if ($_SESSION['groupID']==1) { this was working, then when i changed it to if ($_SESSION['groupID']===1) { per recomendation, it does not now ! i

RE: [PHP] Odd Code Error.

2004-01-21 Thread Robert Cummings
On Thu, 2004-01-22 at 00:52, Martin Towell wrote: [EMAIL PROTECTED] wrote: Ok i found something very interesting , i have a session var setup to check for a groupID which is an integer, if ($_SESSION['groupID']==1) { this was working, then when i changed it to if

[PHP] Odd Code Error.

2004-01-20 Thread Jonathan Pitcher
I am so frustrated at the moment with coding. I had an odd error with some PHP coding. And in the process I came across this error. Please try this out!! Because for me on my machine it does the first part of the if statement. I can make a work around in my code to fix the error. BUT I

Re: [PHP] Odd Code Error.

2004-01-20 Thread Jason Wong
On Wednesday 21 January 2004 06:55, Jonathan Pitcher wrote: if ($EA == NFH) When comparing strings either use '===' or one of the string comparison functions. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting *

RE: [PHP] Odd Code Error.

2004-01-20 Thread Martin Towell
I've come across this recently too. I think what's happening is that PHP is converting NFH to an integer, which would be zero in this case. Thus zero == zero is true... Try doing type checking too: if ($EA === NFH) Martin I am so frustrated at the moment with coding. I had an odd

RE: [PHP] Odd Code Error.

2004-01-20 Thread daniel
i've never had a problem doing if ($var==test) ?? I've come across this recently too. I think what's happening is that PHP is converting NFH to an integer, which would be zero in this case. Thus zero == zero is true... Try doing type checking too: if ($EA === NFH) Martin -- PHP

Re: [PHP] Odd Code Error.

2004-01-20 Thread Brad Pauly
On Tue, 2004-01-20 at 15:55, Jonathan Pitcher wrote: I am so frustrated at the moment with coding. I had an odd error with some PHP coding. And in the process I came across this error. Please try this out!! Because for me on my machine it does the first part of the if statement. I can

Re: [PHP] Odd Code Error.

2004-01-20 Thread daniel
Interesting. I wouldn't have expected that. However, that is how it should work. Check out table K-2 on this page: http://us4.php.net/manual/en/types.comparisons.php '==' is a loose comparison. You can use '===' instead which will give you the results you are looking for. if ($EA ===

Re: [PHP] Odd Code Error.

2004-01-20 Thread Brad Pauly
On Tue, 2004-01-20 at 16:13, [EMAIL PROTECTED] wrote: Interesting. I wouldn't have expected that. However, that is how it should work. Check out table K-2 on this page: http://us4.php.net/manual/en/types.comparisons.php '==' is a loose comparison. You can use '===' instead which will

Re: [PHP] Odd Code Error.

2004-01-20 Thread daniel
Hmm after all this time, are you saying its best to use === instead of == in any application ? I would recommend using it whenever you can. It may require a few extra lines of code here and there, but you know for sure what 'type' you are dealing with. This is especially good when dealing

Re: [PHP] Odd Code Error.

2004-01-20 Thread Tom Rogers
Hi, Wednesday, January 21, 2004, 8:55:01 AM, you wrote: JP I am so frustrated at the moment with coding. I had an odd error with JP some PHP coding. And in the process I came across this error. JP Please try this out!! Because for me on my machine it does the first JP part of the if statement.

Re: [PHP] Odd Code Error.

2004-01-20 Thread Luke
yeah its strange, $test is equal to $test2, $test is equal to $test3 but $test2 is not equal to $test3, $test = string; $test2 = true; $test3 = 0; if($test == $test2){ echo hi; } somone tell me im wrong please? else thats seriously weird -- Luke [EMAIL PROTECTED] wrote in message news:[EMAIL

Re: [PHP] Odd Code Error.

2004-01-20 Thread Robert Cummings
On Tue, 2004-01-20 at 22:39, Luke wrote: yeah its strange, $test is equal to $test2, $test is equal to $test3 but $test2 is not equal to $test3, $test = string; $test2 = true; $test3 = 0; if($test == $test2){ echo hi; } Looks fine to me... $test == $test2: $test is not an empty

Re: [PHP] Odd Code Error.

2004-01-20 Thread Luke
ok, i read the section, but even so if $a == $b and $a == $c then $b should be equal to $c but php is saying otherwise? this sounds confusing i want to try n get my head round it a string equals a integer of zero, and a string equals true, but the reason the bool doesnt equal the int is

Re: [PHP] Odd Code Error.

2004-01-20 Thread Robert Cummings
On Tue, 2004-01-20 at 23:00, Luke wrote: ok, i read the section, but even so if $a == $b and $a == $c then $b should be equal to $c No this is not true, since types conversions can be different between a and b, a and c or between b and c. If you want the above logic to be true then you must

Re: [PHP] Odd Code Error.

2004-01-20 Thread Luke
i think i got it now :) i wont bother trying to explain my understanding, i think that will confuse the matter hehe but i think mainly the usual rule, that if an apple and a banana are fruit, and a pear is the same as a banana, then a pear must be fruit too (AND I think im fruit loops) bah

Re: [PHP] Odd Code Error.

2004-01-20 Thread Jason Wong
On Wednesday 21 January 2004 12:27, Luke wrote: but i think mainly the usual rule, that if an apple and a banana are fruit, and a pear is the same as a banana, then a pear must be fruit too (AND I think im fruit loops) bah im goin bananas, its time to go to band practise anyways, All