为什么我们一般使用getter setter for doctrine2类来保存和获取数据?
如下:
<?php
// src/Product.php
class Product
{
/**
* @var int
*/
protected $id;
/**
* @var string
*/
protected $name;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我们将类属性公开,我们可以在没有getter setter的情况下保存数据.不是吗?
<?php
// src/Product.php
class Product
{
/**
* @var int
*/
public $id;
/**
* @var string
*/
public $name;
}
Run Code Online (Sandbox Code Playgroud) 我从过去3年开始使用zend studio,但不知道我们怎样才能不断增加或减少字体大小.像在一些编辑器中我们使用ctrl ++和ctrl + - 并在一些ctrl和鼠标滚轮.