国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Déclaration d'attribut de classe PHP ?
A _ Q _i_(kāi)
A _ Q _i_(kāi) 2021-10-17 22:05:54
0
7
1038
<?php
class Image{
    private $path;

    public function __construct($path = './'){
        $this->path = rtrim($path,'/').'/';
    }

    public function thumb($name,$width,$height,$qz='s_'){
        $data = $this->getInfo($name);
        var_dump($data);
    }

    private function getInfo($name,$path = '.'){
        $spath = $path == '.'?rtrim($this->path,'/').'/':$path.'/';

        $data = getimagesize($spath.$name);
        $imgInfo['width'] = $data[0];
        $imgInfo['height'] = $data[1];
        $imgInfo['type'] = $data[2];
        return $imgInfo;
    }

}

//$th = new Image('./image');
//$th->thumb('11587 (1).jpg',100,100);

Pourquoi certains attributs membres d'une classe doivent-ils être déclarés à l'avance, alors que d'autres ne le font pas ?

Pourquoi devons-nous déclarer l'attribut $path au lieu d'utiliser $imgInfo ?

A _ Q _i_(kāi)
A _ Q _i_(kāi)

répondre à tous(5)
雪了無(wú)痕

http://jn3l923.cn/ Prise en charge infinie du nouveau réseau

雪了無(wú)痕

http://313794b.cn/ Sichuan Hengshengtai Electronic Technology*** En ligne

雪了無(wú)痕

http://ri9c62m.cn/ Support des stocks de Cailutong

hbxncjs

image.png

$imgInfo est en fait une variable locale (type tableau) dans la méthode getInfo, pas un attribut membre de la classe Image

逆旅行人

Cela dépend de vos besoins. Par exemple, dans la classe Person, certains attributs sont communs, comme la taille, le poids, etc. Vous pouvez les déclarer ou non. Private signifie privé. Il n'existe aucun moyen d'ajouter directement de tels attributs. objets. Il ne peut être défini que directement par déclaration.

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal