PHP在声明属性时将属性设为私有

This declares properties on the fly:

class metadata {

    function __construct($file) {
    /* Argument: Array containing data of a single file */
        while ($pointer = key($file)) {
            $this->$pointer = current($file);
            next($file);
        }
    }
}

I want all the properties that are declared in the while loop as $this->$pointer to be private.

How do I achieve that, without setting a long private $prop1, $prop2, $etc;?

The main purpose is, to keep the code short. The class I am writing probable takes 20 private properties and I was just wondering if I can save the typing.

You can use stdclass. Here is official link, http://us1.php.net//manual/en/reserved.classes.php Like,

class metadata {

    function __construct($file) {
        private $this->file_meta  = new stdClass();
        while ($pointer = key($file)) {
            $this->file_meta->pointer = current($file);
            next($file);
        }
       $this->file_meta->other_var = 'some value'; 
    }
}