Just be aware that POST/GET/COOKIE data is always saved as a string. So if 
someone sends you 2 it'll be the string "2".
If the arguments to your function won't originate from the above but are 
written by the developer then overloading will work well. If not you might 
want to consider splitting the function into two.

Andi

At 02:10 PM 1/5/2002 -0600, Brian Foddy wrote:
>In an external php module project (php-tuxedo),
>we have a group of about 7 php functions that,
>depending on how we design them, could take two different types
>of arguments.
>1.  A integer argument
>2.  A string argument.
>
>If the string argument is given, there is another routine that can
>convert it to the corresponding integer argument, but its not
>guarenteed to match.  Using the integer argument is guarenteed
>to work; hence we really need to support the integer args.
>
>However, the majority of users will want to use the string argument
>because its more intuitive and they should provide the translation
>tables to allow strings to work.
>
>I'd like to come up with a solution flexible enough for both.  And I have
>come up with three different solutions...
>1.  Create two different function names/entry points, one set for ints,
>     one set for strings.
>2.  Overload the function arguments and check which type of arg is being
>    passed.
>3.  Screw it and just accept the ints, and let the users nest a function
>    (in their PHP code) to convert to strings if they want.
>
>Questions...
>1.  Any slick way to do solution 1, say with aliases or something?
>2.  How difficult / successful is it to test the arg type for solution 2.
>
>Let me re-stress, I'm talking about a PHP C code module, not
>PHP code.
>
>I can provide more detailed description if you need.
>Thoughts?
>Brian
>
>
>
>--
>PHP Development 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 Development 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]

Reply via email to