在这个例子中'%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
);
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:令我困惑的部分是编译器如何知道%d指的是哪个变量?它是否按照成员变量的声明顺序排列?