Come faccio a mettere nel campo $b dell'oggetto A il nuovo valore $b?
Codice:class A {
private $b;
public function set_b ($b) {
...
}
}
Printable View
Come faccio a mettere nel campo $b dell'oggetto A il nuovo valore $b?
Codice:class A {
private $b;
public function set_b ($b) {
...
}
}
Codice PHP:
class A {
private $b;
public function set_b ($b) {
$this->b = $b;
}
}
Grazie.
Altra cosa:
Codice:class B {
private $a;
public function __construct ($a) {
$this->a=$a;
}
public function getA () {
return $this->a;
}
}
Mi da l'errore:Codice:$x=new B("ciao");
echo $x.getA();
Codice:Fatal error: Call to undefined function getA()
Devi usare
nonCodice PHP:
echo $x->getA();
Codice PHP:
echo $x.getA();