开发者

some kind off variable problem within php class

I have this in my class

When the second function is called php errors with wrong datatype and only variables can be past by reference.

I don't know what they mean by that

This code comes from php.net If the same code is outside the class it executes fine

What am I doing wrong here, if I am working within a class?

$extensiesAllowed= array();

function __construct() {
        $this->extensiesAllowed= array("txt", "pdf");
        $this->fileName= $_FILES['file'];  
    }


    private function isAllowedExtensie($fileName) {

    return in_array(end(explode(".", $f开发者_C百科ileName)), $this->extensiesAllowed);
    }



public function check_upload() {

        if($this->fileName['error'] == UPLOAD_ERR_OK) {
            if(isAllowedExtensie($this->fileName['name'])) {
            return true;

            }   
        }
    } 

the php error shows

Array
(
    [bestandsNaam] => ACCOUNT INFO.txt
    [extensiesAllowed] => 
)

Thanks, Richard


try putting the end and explode in seperate statements - I think end() may read by reference. In any case, it will help you figure out what line is causing you problems if it doesnt fix it.


In the second function/method you should call should be calling isAllowedExtensie as $this-> isAllowedExtensie()

if($this->isAllowedExtensie($this->fileName['name'])) {

Edit: forget my second comment..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜