この例では、 '%s'と '%d'はどういう意味ですか?これは、変数を呼び出すための省略表現です。この構文はクラス内でのみ機能しますか?変数 '%s'と '%d'は変数の呼び出しの略語とは何を意味しますか?
// Class
class Building {
// Object variables/properties
private $number_of_floors = 5; // These buildings have 5 floors
private $color;
// Class constructor
public function __construct($paint) {
$this->color = $paint;
}
public function describe() {
printf('This building has %d floors. It is %s in color.',
$this->number_of_floors,
$this->color
);
}
}
EDIT:私に混乱した部分は、コンパイラは変数%dはを参照しているかを知るんですか?メンバー変数が宣言された順に並んでいますか?
マニュアルは非常によく、このすべてを説明する。.. http://php.net/sprintfを参照してください。 –