Re: [PHP] Strong typing?

2001-07-13 Thread Adam

 why can't you just use plan simple HTML to do it??? rather than make a
larger hassle for your self ie

 strong howdy /strong ???

  yes that is valid HTML :)

 Peter

why do i get the idea that's not what they meant...

-Adam



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Strong typing?

2001-07-13 Thread scott [gts]

and as far as i know, perl's 'strict mode' has absolutely
nothing to do with typing of variables...

use strict; will force you to define all variables
with my $var; or local $var; before you assign values
to them or try and use them... but it doesnt do anything
about enforcing typing... 

in perl 6, i think that plans are under way to add
extensions that will let people strongly-type
variables if they want (but it still wont be mandatory)

example: my integer $number = 5;

would stronlgy-type that variable as an integer, and
you wouldnt be able to assign any other type of value
to it without an error.  but i dont know how far the
developers will go towards realizing strongly-typed
extensions to perl... 

as rasmus said... it's incredibly hard to have it both
ways.  the freedom of perl and PHP largely comes from
*not* having to always worry about variable typing,
memory allocation/cleanup and all those other nitpicky
low-level things that BDSM ... errr C programmers
seem to love  :-)


 -Original Message-
 From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 12, 2001 8:15 PM
 To: Dr. Evil
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Strong typing?
 
 
  PHP is a great language.  It makes it fast and easy to create web
  pages.  However, one feature which is critical for doing rock-solid
  stable websites is strong typing.  The reason for this is that you're
  dealing with untrusted user input.  Strong typing helps because if you
  are expecting an INT, and the user gave you something else, and you
  made a mistake in your input checking, the program will fail when you
  attempt to assign the value to the strongly-type INT variable.  This
  is a good thing when you are dealing with money, or other contexts
  where you need very solid code.
 
  First, is there a plan to introduce a strong typing option, like
  perl's strict mode?
 
  Second, is there a way to get something equivalent to strong typing
  using the class system?
 
 You can't really have it both ways.  And no, there is no plan to implement
 strong typing.
 
 -Rasmus
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Strong typing?

2001-07-12 Thread Chadwick, Russell


http://www.php.net/manual/en/function.settype.php

is this what you are looking for?

-Original Message-
From: Dr. Evil [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 12, 2001 4:55 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Strong typing?



PHP is a great language.  It makes it fast and easy to create web
pages.  However, one feature which is critical for doing rock-solid
stable websites is strong typing.  The reason for this is that you're
dealing with untrusted user input.  Strong typing helps because if you
are expecting an INT, and the user gave you something else, and you
made a mistake in your input checking, the program will fail when you
attempt to assign the value to the strongly-type INT variable.  This
is a good thing when you are dealing with money, or other contexts
where you need very solid code.

First, is there a plan to introduce a strong typing option, like
perl's strict mode?

Second, is there a way to get something equivalent to strong typing
using the class system?

Thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Strong typing?

2001-07-12 Thread Brian White

U... you could write a fuction like

function CheckInputAgainstRE( $val, $re )
{
 if ( ! ereg( $re, $val ) )
 {
 ( ... some kind of code that writes out an error message and dies 
... )
 }
 return $val;
}

and then a series of functions like

function CheckInt( $val )
{
 return (integer)CheckInputAgainstRE( $val, ^-?[0-9]+$ );
}

which you could then use as your input protection

Would that help?

Brian

At 23:55 12/07/2001 +, Dr. Evil wrote:

PHP is a great language.  It makes it fast and easy to create web
pages.  However, one feature which is critical for doing rock-solid
stable websites is strong typing.  The reason for this is that you're
dealing with untrusted user input.  Strong typing helps because if you
are expecting an INT, and the user gave you something else, and you
made a mistake in your input checking, the program will fail when you
attempt to assign the value to the strongly-type INT variable.  This
is a good thing when you are dealing with money, or other contexts
where you need very solid code.

First, is there a plan to introduce a strong typing option, like
perl's strict mode?

Second, is there a way to get something equivalent to strong typing
using the class system?

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-
Brian White
Step Two Designs Pty Ltd - SGML, XML  HTML Consultancy
Phone: +612-93197901
Web:   http://www.steptwo.com.au/
Email: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Strong typing?

2001-07-12 Thread Rasmus Lerdorf

 PHP is a great language.  It makes it fast and easy to create web
 pages.  However, one feature which is critical for doing rock-solid
 stable websites is strong typing.  The reason for this is that you're
 dealing with untrusted user input.  Strong typing helps because if you
 are expecting an INT, and the user gave you something else, and you
 made a mistake in your input checking, the program will fail when you
 attempt to assign the value to the strongly-type INT variable.  This
 is a good thing when you are dealing with money, or other contexts
 where you need very solid code.

 First, is there a plan to introduce a strong typing option, like
 perl's strict mode?

 Second, is there a way to get something equivalent to strong typing
 using the class system?

You can't really have it both ways.  And no, there is no plan to implement
strong typing.

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Strong typing?

2001-07-12 Thread Dr. Evil


 U... you could write a fuction like
 
 function CheckInputAgainstRE( $val, $re )
 {
  if ( ! ereg( $re, $val ) )
  {
  ( ... some kind of code that writes out an error message and dies 
 ... )
  }
  return $val;
 }

That's what I've done.  I have a huge file full of all kinds of data
checking functions.  However, what if I forget to call one of them, or
one doesn't work the way I expect it to?  Strong typing means that the
script will just die, instead of possibly passing the wrong values
into the SQL query.  This is exactly the same reason why perl has a
strict mode.  Sure you could write a lot of input checking functions
(which you will have to do no matter what) but you should have
constraints built into your data structures.

It's just like with SQL: if you know that a certain value in a table
has a certain constraint (a withdrawal must always be greater than
zero) then you should put that constraint into your table definition,
so that an error somewhere else will be limited in its effects.

If you're doing financial stuff, or anything else that requires
bullet-proof security and reliability, strong typing is essential, in
addition to checking all the user input.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Strong typing?

2001-07-12 Thread Phil Driscoll

On Friday 13 July 2001 01:27, Dr. Evil wrote:

 If you're doing financial stuff, or anything else that requires
 bullet-proof security and reliability, strong typing is essential,

I would have said that good programming was essential rather than strong 
typing.

If you insist on strong typing, then PHP is not the language for you!

-- 
Phil Driscoll

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Strong typing?

2001-07-12 Thread Peter Houchin - SunRentals Australia

why can't you just use plan simple HTML to do it??? rather than make a larger hassle 
for your self ie

strong howdy /strong ??? 

 yes that is valid HTML :)

Peter

-Original Message-
From: Dr. Evil [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 13, 2001 10:27 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Strong typing?



 U... you could write a fuction like
 
 function CheckInputAgainstRE( $val, $re )
 {
  if ( ! ereg( $re, $val ) )
  {
  ( ... some kind of code that writes out an error message and dies 
 ... )
  }
  return $val;
 }

That's what I've done.  I have a huge file full of all kinds of data
checking functions.  However, what if I forget to call one of them, or
one doesn't work the way I expect it to?  Strong typing means that the
script will just die, instead of possibly passing the wrong values
into the SQL query.  This is exactly the same reason why perl has a
strict mode.  Sure you could write a lot of input checking functions
(which you will have to do no matter what) but you should have
constraints built into your data structures.

It's just like with SQL: if you know that a certain value in a table
has a certain constraint (a withdrawal must always be greater than
zero) then you should put that constraint into your table definition,
so that an error somewhere else will be limited in its effects.

If you're doing financial stuff, or anything else that requires
bullet-proof security and reliability, strong typing is essential, in
addition to checking all the user input.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]