-
Notifications
You must be signed in to change notification settings - Fork 830
Rework documentation for dir functions #4989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Include 8.5 deprecation for passing null to use the last opened directory.
f808a54 to
136c097
Compare
| <simpara> | ||
| Because file and directory names can be strings that PHP considers "falsy" | ||
| (e.g. a directory named <literal>"0"</literal>) and | ||
| <function>readdir</function> returns &false; when it has read all entries | ||
| in a directory one needs to use the <literal>===</literal> | ||
| <link linkend="language.operators.comparison">comparison operator</link> | ||
| to properly distinguish between a directory entry whose name is "falsy" | ||
| and having read all entries of the directory. | ||
| </simpara> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this need to be a warning or a note?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, maybe could even be a caution.
| <![CDATA[ | ||
| filename: . : filetype: dir | ||
| filename: .. : filetype: dir | ||
| filename: apache : filetype: dir | ||
| filename: cgi : filetype: dir | ||
| filename: cli : filetype: dir | ||
| ]]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output doesn't match the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't really have any output because it might be any filesystem, that's why we use the &example.outputs.similar; entity rather than &example.outputs;.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mean the file names. I meant the overal output structure is from the old example. You copied the other example without the copying the output also.
| <?php | ||
| if ($handle = opendir('/path/to/files')) { | ||
| echo "Directory handle: $handle\n"; | ||
| echo "Entries:\n"; | ||
| /* This is the correct way to loop over the directory. */ | ||
| while (false !== ($entry = readdir($handle))) { | ||
| echo "$entry\n"; | ||
| } | ||
| /* This is the WRONG way to loop over the directory. */ | ||
| while ($entry = readdir($handle)) { | ||
| echo "$entry\n"; | ||
| } | ||
| closedir($handle); | ||
| } | ||
| ?> | ||
| ]]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You copied it from here and this didn't have the output section.
Include 8.5 deprecation for passing null to use the last opened directory.