Re: Unexcepted $this

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Murat BEŞER wrote:
I can't under stood but PHP gaves me an error:

"UnExcepted $this" for " || $this->getFileExtension($file) == 'jpg' "

When I removed jpg extension check it's okay... PHP script runs well.

What is the problem :)

public function loadImages($folder) {
        $result = $this->filemanager->fecthFiles($folder);
        $images = array();
        if (sizeof($result)>=1 && $result !== false) {
            foreach ($result as $file) {
if ($this->getFileExtension($file) == 'gif' || $this->getFileExtension($file) == 'png' || $this->getFileExtension($file) == 'jpg') {
                    $images[] = array('name'=>$file);
                }
            }
        }
        return $images;
    }


Try storing the value in a variable first. It'll also have the side-effect of being marginally faster too.

$extension = $this->getFileExtension($file);

if ($extension == 'gif' || $extension || 'png' || $extension == 'jpg') {
	// do something
}

That might help, but I would think that the way you had it would also work. Let us know what happens when you use the variable like I showed above.

Thanks,
--
Ray Hauge
www.primateapplications.com

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux