Browse Source

fragments/empty.php: php empty()

Demonstrate a couple of gotchas with `empty()` in PHP.
Brennen Bearnes 8 months ago
parent
commit
5124aa8353
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      home/fragments/empty.php

+ 7
- 0
home/fragments/empty.php View File

@@ -0,0 +1,7 @@
1
+#!/usr/bin/env php
2
+<?php
3
+// 0 is empty:
4
+if (empty(0)) print "here's your gotcha\n";
5
+
6
+// "0" is empty:
7
+if (empty("0")) print "here's your other gotcha\n";

Loading…
Cancel
Save