Re: Strong typing?
| From: | Brian White | Date: | Fri, 13 Jul 2001 00:03:08 +0000 |
| Subject: | Re: Strong typing? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-57656@lists.php.net to get a copy of this message | ||
Ummmm... 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 +0000, 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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net------------------------- Brian White Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: bwhite@steptwo.com.au