FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Verifying time in php
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Verifying time in php [message #179380 is a reply to message #179379] Sun, 14 October 2012 15:16 Go to previous messageGo to previous message
houghi is currently offline  houghi
Messages: 45
Registered: September 2011
Karma:
Member
J.O. Aho wrote:
> Validate what you get and make a sanity check on what you got before you
> calculate the realtime value.
>
>
>> I just want to figure out how I can check if Hours, Minutes and Seconds
>> input is valid.
>
> There are quite many is_* functions, among those you have
> is_numeric()[1] and another one is isset()[2] which gives you true or false.
>
>
> [1]: http://www.php.net/manual/en/function.is-numeric.php
> [2]: http://www.php.net/manual/en/function.isset.php

I am aware of those. However I can not figure out how to do a check on
all of them, without getting lost in if statements.

See below where '-' means empty, 1 means any digit(s) and A means any no
digit(s). I have not shown all options.

Valid? $hours $min $sec
No - - -
Yes 1 - -
Yes 1 - 1
Yes - 1 -
Yes 1 1 1
No A - -
No 1 A -
No 1A - -

So I have to figure out if some are filled out and if they are, if they
are digits. Looking around for 2 days now to make it intro something
can read next week as well.

I keep getting back to where I need to get through all options.

So is_numeric is obvious as well as is_set, but is_set is not needed if
others are set.

houghi
--
This is written under the inluence of the following:
> Artist : Apocalyptica
> Song : Hope (Vol.2) (Radio Edit)
> Album : Hope Vol.2
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Curl chmod file transfer problem...
Next Topic: test
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 15:12:31 GMT 2024

Total time taken to generate the page: 0.03931 seconds