1
Error give on line 13 of index.php
when I try to create a new object "$c = new controleremoto"
says the class doesn’t exist.
I’m new to programming and I’ve tried everything, changed folder, I’ve googled the error and in several results I couldn’t find the answer. If anyone can help me I thank you from my heart.
This error appears when I access index.php
Fatal error: Uncaught Error: Class 'controleremoto' not found in /opt/lampp/htdocs/edubr/index.php:13 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/edubr/index.php on line 13
If you need more information I’m at your disposal I think I put it all here. I’m starting now please be patient.
php controller.
<?php
interface controlador {
public function ligar();
public function desligar();
public function abrimenu();
public function fechamenu();
public function maisvolume();
public function menosvolume();
public function ligarmudo();
public function desligarmudo();
public function play();
public function pause();
}
?>
Remote Control.php
<?php
require_once 'controlado.php';
class controleremoto implements controlador {
// atributos
private $volume;
private $ligado;
private $tocando;
// metodos especiais
function __construct() {
$this->volume = 50;
$this->ligado = false;
$this->tocando = false;
}// gets
function getvolume() {
return $this->volume;
}
function getligado() {
return $this->ligado;
}
function gettocando() {
return $this->tocando;
}// settes
function setvolume($volume) {
$this->volume = $volume;
}
function setligado($ligado) {
$this->ligado = $ligado;
}
function settocando($tocando) {
$this->tocando = $tocando;
}// metodos abstrados
public function abrimenu() {
echo "<br> Estar ligado?:" . ($this->getligado() ? "sim":"não");
echo "<br está tocando?:" . ($this->gettocando()?"sim":"não");
echo "<br> volume:" . $this->getvolume();
for ($i=0; $i <= $this->getvolume(); $i+=10) {
echo "i";
}
echo "<br>";
}
public function fechamenu() {
echo "<br>fechando muenu..";
}
public function desligar() {
$this->setligado(false);
}
public function ligar() {
$this->setligado(true);
}
public function maisvolume() {
if ($this->getligado()) {
$this->setvolume ($this->getvolume() + 5);
}
}
public function menosvolume() {
if ($this->getligado()) {
$this->setligado($this->getvolume() - 5);
}
}
public function ligarmudo() {
if ($this->getligado() && $this->getvolume() >0) {
$this->setvolume(0);
}
}
public function desligarmudo() {
if ($this->getligado() && $this->getvolume() ==0) {
$this->setvolume(50);
}
}
public function play() {
if ($this->getligado() && ! ($this->gettocando())) {
$this->settocando(true);
}
}
public function pause() {
if ($this->getligado() && $this->gettocando()) {
$this->settocando(false);
}
}
}
?>
index php.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>curso em video</title>
</head>
<body>
<h1> projeto controle remoto </h1>
<?php
require_once 'controlador.php';
$c = new controleremoto();
$c->ligar();
$c->abrimenu();
?>
</body>
</html>
It worked well! Thank you Oberto I’m still finishing the course of Opoo and I hadn’t learned that. about the missing r was more than 06 hours trying to make it work and nothing. thank you very much...
– Afiliado Edubr
How great it worked! Good studies for you!
– Roberto Griel Filho