Warning: Undefined array key 111121 in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3534

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3536

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/user.php on line 704

Warning: Undefined array key "online" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3548

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Undefined array key 111121 in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3534

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3536

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/user.php on line 704

Warning: Undefined array key "online" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3548

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Undefined array key 111121 in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3534

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3536

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/user.php on line 704

Warning: Undefined array key "online" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3548

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Undefined array key 111121 in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3534

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3536

Warning: Trying to access array offset on value of type null in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/user.php on line 704

Warning: Undefined array key "online" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/content.php on line 3548

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Trying to access array offset on value of type bool in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 635

Warning: Undefined array key "birthday_search" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 173

Warning: Undefined array key "joindate" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 190

Warning: Undefined array key "posts" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 191

Warning: Undefined array key "posts" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 197

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 6509

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 212

Warning: Undefined array key "privacy_options" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 251

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 4998

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 1585

Warning: Undefined array key "lastactivity" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 1601

Warning: Trying to access array offset on value of type bool in /home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb5/route/profile.php on line 74
Errata - MC Press Online Forums

Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Errata

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • jeffolen4
    replied
    Chapter 6

    Chris,

    You are correct in all of your observations.

    However the point of this sample code was to demonstrate the usage of the is_dir, is_file and is_link. I think we made the statement several times throughout the book that the code samples are not to be confused with production code. This being both from a best practices standpoint and an error handling standpoint.

    Thanks,
    Jeff Olen

    Leave a comment:


  • RingerSoftware
    replied
    Why does the script hardcode the directory separator? In Windows, it's a backslash, so this code is already not portable. And the file name might need to be encoded (safe) before sending to browser. Try this instead:


    define(DS, DIRECTORY_SEPARATOR) ; // ... is / on nix and \ on Windows
    define(BR,'<br>') ;
    $dirName = DS . 'etc';
    $dir = opendir($dirName);

    while ( ($file = readdir($dir)) ) {
    $tempFile = $dirName . DS . $file ;
    $tempFileSafe = htmlentities($tempFile, ENT_QUOTES);
    if (is_dir($tempFile)) {
    echo "Directory: $tempFileSafe", BR;
    } elseif (is_file($tempFile)) {
    echo "File: $tempFileSafe", BR;
    } elseif (is_link($tempFile)) {
    echo "Link: $tempFileSafe", BR;
    } else {
    echo "Unknown: $tempFileSafe", BR;
    }
    }
    closedir($dir);


    Chris
    Last edited by RingerSoftware; 07-11-2009, 08:59 PM.

    Leave a comment:


  • M.Lee
    started a topic Errata

    Errata

    The following file has Errata pertaining to Chapter 6.

    Errata.pdf
    Last edited by Guest; 07-09-2009, 03:21 PM.
Working...
X