On 12-10-2012 06:10, tamouse mailing lists wrote:
if (
        ! is_dir($dirBase."/".$get_the_album) // this is not a directory
     || ! strpos($get_the_album, '.')         // directory name does
not contain a period
     || ! strpos($get_the_album, '\')         // directory name does
not contain a backslash
    )
    {


Don't use ! strpos() to check if it does not contain a character. The reason for this is that:
strpos('.text', '.') == false
This is because strpos('.something', '.') returns 0, which evaluates to false.

So instead, you should use:
strpos($get_the_album, '.') !== false to check if $get_the_album does not contain the character '.'

However, this is likely not what the OP wants. What he likely does want is to check if the filename is not '.' or '..'. Of course, there are numerous ways to do this. From very simple things like:
if ( $filename != '.' && $filename != '..')
to
if (false === array_search($filename, array('.','..')) {

As Lester mentioned, there are tons of ways to resolve a 'problem', and most of them are usually good.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to