User Tools

Site Tools


docs:tips_n_tricks:php.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docs:tips_n_tricks:php.html [08.03.2012 09:53 CET] peterdocs:tips_n_tricks:php.html [08.03.2012 10:23 CET] (current) peter
Line 10: Line 10:
  
   <?   <?
 +    print "PHP Version is ".phpversion()."\n";
 +  
 +    print '+---------------';
 +    print '+-----------' ;
 +    print '+-----------' ;
 +    print "+\n";
 +  
 +    print '| value         ';
 +    print '| isset()   ' ;
 +    print '| empty()   ' ;
 +    print "|\n";
 +  
 +    print '+---------------';
 +    print '+-----------' ;
 +    print '+-----------' ;
 +    print "+\n";
      
     print '| $foobar       ';     print '| $foobar       ';
Line 34: Line 50:
     else               print '| not empty ' ;     else               print '| not empty ' ;
     print "|\n";     print "|\n";
 +  
     print '| $foobar = 42  ';     print '| $foobar = 42  ';
     $foobar = 42;     $foobar = 42;
Line 66: Line 82:
     else               print '| not empty ' ;     else               print '| not empty ' ;
     print "|\n";     print "|\n";
 +  
 +    print '+---------------';
 +    print '+-----------' ;
 +    print '+-----------' ;
 +    print "+\n";
 +
 +or
 +
 +  <?
 +    print "PHP Version is ".phpversion()."\n";
 +    
 +    print '+-------------------';
 +    print '+-----------' ;
 +    print '+-----------' ;
 +    print "+\n";
 +  
 +    print '| value             ';
 +    print '| isset()   ' ;
 +    print '| empty()   ' ;
 +    print "|\n";
 +  
 +    print '+-------------------';
 +    print '+-----------' ;
 +    print '+-----------' ;
 +    print "+\n";
 +  
 +    printf('| $foobar   %-7s | %-9s | %-9s |'."\n",''       ,(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +  
 +    $foobar = 0;
 +    printf('| $foobar = %-7s | %-9s | %-9s |'."\n",'0'      ,(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +  
 +    $foobar = "";
 +    printf('| $foobar = %-7s | %-9s | %-9s |'."\n",'""'     ,(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +  
 +    $foobar = 42;
 +    printf('| $foobar = %-7s | %-9s | %-9s |'."\n",'42'     ,(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +      $foobar = "42";
 +    printf('| $foobar = %-7s | %-9s | %-9s |'."\n",'"42"'   ,(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +  
 +    $foobar = "x";
 +    printf('| $foobar = %-7s | %-9s | %-9s |'."\n",'"x"'    ,(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +  
 +    $foobar = array();
 +    printf('| $foobar = %-7s | %-9s | %-9s |'."\n",'array()',(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +  
 +    $foobar = NULL;
 +    printf('| $foobar = %-7s | %-9s | %-9s |'."\n",'NULL'   ,(isset($foobar) ? '' : 'not ').'set',(empty($foobar) ? '' : 'not ').'empty' );
 +  
 +    print '+-------------------';
 +    print '+-----------' ;
 +    print '+-----------' ;
 +    print "+\n";
 +
 +
  
 gives  gives 
  
 +  PHP Version is 5.3.8
 +  +---------------+-----------+-----------+
 +  | value         | isset()   | empty()   |
 +  +---------------+-----------+-----------+
   | $foobar       | not set   | empty     |   | $foobar       | not set   | empty     |
   | $foobar = 0   | set       | empty     |   | $foobar = 0   | set       | empty     |
Line 76: Line 150:
   | $foobar = "x" | set       | not empty |   | $foobar = "x" | set       | not empty |
   | $foobar = NULL| not set   | empty     |   | $foobar = NULL| not set   | empty     |
 +  +---------------+-----------+-----------+
 +
  
docs/tips_n_tricks/php.html.1331196825.txt.gz · Last modified: 08.03.2012 09:53 CET by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki