2

I'm currently using:

if (isset($get['when']) && !strtotime($get['when']) && strtotime($get['when']) < time())

But i would also like it to include a way to check if $get['when'] is empty(''). How do I do this in the best manner?

KJYe.Name
  • 16,969
  • 5
  • 48
  • 63
Himmators
  • 14,278
  • 36
  • 132
  • 223

3 Answers3

1

empty( $get['when'] ) will return true if $get['when'] is an empty string. See the manual's entry on empty for more info.

Chuck
  • 4,662
  • 2
  • 33
  • 55
0
if (isset($get['when']) && !empty($_GET['when']) && !strtotime($get['when']) && strtotime($get['when']) < time())

Use the empty function straight after you check that $_GET['when'] is set.

Gazler
  • 83,029
  • 18
  • 279
  • 245
  • 1
    empty performs several checks, 1 being if the variable is set, and another being the variable length, there is no need for the isset, please see the manual – RobertPitt Apr 11 '11 at 16:53
-1
if(isset($get['when']) && !empty($get['when']) ...
animuson
  • 53,861
  • 28
  • 137
  • 147
Adam Hopkinson
  • 28,281
  • 7
  • 65
  • 99