RE: [PHP] Require variable declaration?
You can catch typos by setting the error reporting level to E_ALL (in php.ini). PHP will then give you a warning whenever a variable is used before it has been assigned a value. Kirk > That's too bad, > I used to do some ASP which is weakly typed too but I still > could use "Option Explicit" to require variables to be declared. > Then a small typo would produce very hard-to-find errors. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Require variable declaration?
There has been some discussion at zend.com to add this to PHP5/engine 2.0. However, the idea was rejected. -Original Message- From: Kjell Hansen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 2:54 PM To: Rick Emery; [EMAIL PROTECTED] Subject: Re: [PHP] Require variable declaration? That's too bad, I used to do some ASP which is weakly typed too but I still could use "Option Explicit" to require variables to be declared. Then a small typo would produce very hard-to-find errors. Well, I guess I have to live with it. Can I add it to a PHP5-wishlist? Thanx /Kjell - Original Message - From: "Rick Emery" <[EMAIL PROTECTED]> To: "'Kjell Hansen'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, March 27, 2002 10:45 PM Subject: RE: [PHP] Require variable declaration? > PHP is weakly typed. Therefore, definitions are not needed. A variable may > assume any guise depending upon its context. > > -Original Message- > From: Kjell Hansen [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, March 27, 2002 2:47 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Require variable declaration? > > > Hi, > I've just started making my database/PHP-scripts and I'm used to, from > my earlier development, have my variables declared at the top of each > routine. > But I can't find the command that would force me to declare my variables > and I can't find the declare statement either. > > Is there a way to do this? > > Regards > /Kjell > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Require variable declaration?
That's too bad, I used to do some ASP which is weakly typed too but I still could use "Option Explicit" to require variables to be declared. Then a small typo would produce very hard-to-find errors. Well, I guess I have to live with it. Can I add it to a PHP5-wishlist? Thanx /Kjell - Original Message - From: "Rick Emery" <[EMAIL PROTECTED]> To: "'Kjell Hansen'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, March 27, 2002 10:45 PM Subject: RE: [PHP] Require variable declaration? > PHP is weakly typed. Therefore, definitions are not needed. A variable may > assume any guise depending upon its context. > > -Original Message- > From: Kjell Hansen [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, March 27, 2002 2:47 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Require variable declaration? > > > Hi, > I've just started making my database/PHP-scripts and I'm used to, from > my earlier development, have my variables declared at the top of each > routine. > But I can't find the command that would force me to declare my variables > and I can't find the declare statement either. > > Is there a way to do this? > > Regards > /Kjell > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Require variable declaration?
You don't need to do this with PHP... a variable is created when you assign a value to it. It is also unnecessary to assign a type. PHP will typecast automatically as necessary -Original Message- From: Kjell Hansen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 12:47 PM To: [EMAIL PROTECTED] Subject: [PHP] Require variable declaration? Hi, I've just started making my database/PHP-scripts and I'm used to, from my earlier development, have my variables declared at the top of each routine. But I can't find the command that would force me to declare my variables and I can't find the declare statement either. Is there a way to do this? Regards /Kjell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Require variable declaration?
PHP is weakly typed. Therefore, definitions are not needed. A variable may assume any guise depending upon its context. -Original Message- From: Kjell Hansen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 2:47 PM To: [EMAIL PROTECTED] Subject: [PHP] Require variable declaration? Hi, I've just started making my database/PHP-scripts and I'm used to, from my earlier development, have my variables declared at the top of each routine. But I can't find the command that would force me to declare my variables and I can't find the declare statement either. Is there a way to do this? Regards /Kjell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php