You are here: Class method returns both TRUE and FALSE at the exact same time!! « PHP Programming Language « IT news, forums, messages
Class method returns both TRUE and FALSE at the exact same time!!

Posted by comp.lang.php on 07/24/06 21:49

[PHP]
class ThumbView extends PaginationView {

function ThumbView() {}

/**
* Determine if the original image is actually an image and thus a
thumbnail can be generated at all
*
* @access public
* @param mixed $image_name (optional)
* @param mixed $album (optional)
* @param mixed $section (optional)
* @return boolean
* @see mime_content_type
* @see actual_path
*/
function isImage($image_name = '', $album = '', $section = '')
{ // BOOLEAN METHOD
/*--------------------------------------------------------------------------------------------------------------------------------------------------------
ResizeView will inherit ThumbView::isImage() method now and thus
will have its own instance of $this->id in existence
which is the image name and not an actual id (other instances of
$this->id in class objects inheriting this method will
be numeric by database design). Set the obtainably inherited
$this->{$section . '_name'} to $this->id.
---------------------------------------------------------------------------------------------------------------------------------------------------------*/
if (!$section) global $section;
global ${$section . 'LocationPath'};
if (!$this->{$section . '_name'} || $image_name)
ThumbView::setThumbViewProperties($image_name, $album);
if ($this->{$section . '_name'}) {
if (strlen($this->album) > 0) $album = $this->album;
$locationPath = ($album) ? "${$section . 'LocationPath'}/$album" :
${$section . 'LocationPath'};
$imgStatArray = @getimagesize(actual_path("$locationPath/" .
$this->{$section . '_name'}));
if (!is_array($imgStatArray) || @sizeof($imgStatArray) == 0) return
false;
print_r("111<P>");
if (preg_match('/^image\//i',
@mime_content_type(actual_path("$locationPath/" . $this->{$section .
'_name'})))) return true;
print_r("222<P>");
}
print_r("333<P>");
return false; // WILL EVEN RETURN FALSE IF NO IMAGE NAME IS PROVIDED
SINCE IMPOSSIBLE TO DETERMINE IF ?? IS AN IMAGE OR NOT
}

}

[/PHP]

This class method, isImage(), for some bizarre reason, has the uncanny
ability to return both TRUE **AND** FALSE literally at the exact same
time, or so it seems!

This will be your output:

[quote]
111
333
[/quote]

Based on this logic flow, that means that it should have returned true
and that's it, but for some bizarre reason it is literally capable of
returning true, then suddenly returning false, even though the method
is called "statically":

[PHP]
if (!ThumbView::isImage($fileName, $_REQUEST['album'])) {
print_r("This is not an image<P>"); // ALWAYS PRINTS THIS EVEN IF IT
*IS* AN IMAGE!!
}
[/PHP]

Has anyone ever seen this within a statically called class method ever
in PHP?

Phil

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация