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,531
  • 5
  • 47
  • 62
Himmators
  • 13,568
  • 33
  • 122
  • 214

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,422
  • 1
  • 25
  • 52
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
  • 81,193
  • 17
  • 276
  • 242
  • 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
  • 52,378
  • 28
  • 138
  • 145
Adam Hopkinson
  • 27,556
  • 7
  • 64
  • 93