I have the class below:
<?php
namespace CONSTANTES;
class Constantes {
private $livre = true;
private $util;
private $site = array (
"dominio" => "crud.com.br",
"www" => "www.crud.com.br",
"http" => "http://www.crud.com.br",
"tituloSite" => "CRUD SITE",
"tituloAdmin" => "CRUD Administração",
"tituloLoja" => "CRUD LOJA",
"descricao" => "???",
"keywords" => "???",
"fundacao" => "???",
"ano" => "2018",
"proprietario" => "???",
"proprietarioDcto" => "???"
);
private $siteEndereco = array (
"rua" => "???",
"numero" => "???",
"complemento" => "???",
"bairro" => "???",
"cidade" => "???",
"estado" => "???",
"cep" => "???"
);
private $siteEnderecoCompleto;
private $siteTelefones = array (
"ddd" => "???",
"tel" => "???",
"cel" => "???"
);
private $siteRedesSocias = array (
"facebook" => "http://www.facbook.com/crud",
"instagram" => "http://www.instagram.com/crud",
"whatsapp" => "???"
);
private $imgDir = "_img";
private $charset = "UTF-8";
public function __construct($_util) {
if($this->livre == false) {
header("Location: ".$_SERVER["SERVER_PATH"]."/manutencao.php");
exit;
}
$this->util = $_util;
$this->siteEnderecoCompleto =
$this->siteEndereco["rua"]. ", ";
$this->siteEndereco["numero"]. ", ";
$this->siteEndereco["complemento"]. ", ";
$this->siteEndereco["bairro"]. ", ";
$this->siteEndereco["cidade"]. ", ";
$this->siteEndereco["estado"]. ", ";
$this->util->formataCep($this->siteEndereco["cep"]). ", ";
}
public function getLivre() {
return $this->livre;
}
public function getSite() {
return $this->site;
}
public function getSiteEndereco() {
return $this->siteEndereco;
}
public function getSiteEnderecoCompleto() {
return $this->getSiteEnderecoCompleto();
}
public function getSiteTelefones() {
return $this->siteTelefones;
}
public function getSiteRedesSociais() {
return $this->siteRedesSocias;
}
public function getImagemDir() {
return $this->imgDir;
}
public function getCharset() {
return $this->charset;
}
}
?>
As is a class of properties that are immutable via code. That is, they are constant. I would like to add static
to them. As below:
<?php
namespace CONSTANTES;
class Constantes {
static private $livre = true;
static private $util;
...
But this practice changes the value from $livre
to false
;
How can I do this?
I've also tried:
static private final $livre = true;
Give it to me!