Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal tenho o seguinte erro:
Fatal error: Cannot redeclare class falecimentoDTO in C:\xampp5\htdocs\grupocolombano.com.br\DTO\falecimentoDTO.php on line 14
falecimentoDTO.php :
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of falecimentoDTO
*
* @author MARKETING
*/
class falecimentoDTO <-Linha 14 {
private $id;
private $nome;
private $informa;
private $img;
private $datanascimento;
private $datafalecimento;
private $status;
private $op;
function getId() {
return $this->id;
}
function getNome() {
return $this->nome;
}
function getInforma() {
return $this->informa;
}
function getImg() {
return $this->img;
}
function getDatanascimento() {
return $this->datanascimento;
}
function getDatafalecimento() {
return $this->datafalecimento;
}
function getStatus() {
return $this->status;
}
function getOp() {
return $this->op;
}
function setId($id) {
$this->id = $id;
}
function setNome($nome) {
$this->nome = $nome;
}
function setInforma($informa) {
$this->informa = $informa;
}
function setImg($img) {
$this->img = $img;
}
function setDatanascimento($datanascimento) {
$this->datanascimento = $datanascimento;
}
function setDatafalecimento($datafalecimento) {
$this->datafalecimento = $datafalecimento;
}
function setStatus($status) {
$this->status = $status;
}
function setOp($op) {
$this->op = $op;
}
}
falecimentoINT.php Aonde a classe esta sendo chamada:
<?php
require_once '../DTO/falecimentoDTO.php';
require_once '../CTR/falecimentoCTR.php';
require_once '../CTR/materiaCTR.php';
$falecimentoDTO = new falecimentoDTO();
$falecimentoCTR = new falecimentoCTR();
$materiaCTR = new materiaCTR();
$falecimentoDTO->setDatafalecimento($_POST['datafalecimento']);
$falecimentoDTO->setDatanascimento($_POST['datanascimento']);
$falecimentoDTO->setInforma($_POST['informa']);
$falecimentoDTO->setNome($_POST['nome']);
$falecimentoDTO->setStatus($_POST['status']);
$imagem = $materiaCTR->trataFoto($_FILES['imagem'], $_POST['nome_ant'], 555, 310, $txt);
$falecimentoDTO->setImg($imagem);
print_r($falecimentoDTO);
if (isset($_POST['cad'])) {
$falecimentoDTO->setOp(1);
if ($falecimentoCTR->modificarFalecimento($falecimentoDTO)) {
// echo "<script>location.href ='../cmsbr/listarMateriaVIEW.php?cad=ok';</script>";
} else {
//echo "<script>location.href ='../cmsbr/listarMateriaVIEW.php?cad=fail';</script>";
}
}
}
Já fiz de tudo e não acho o problema! Alguem ai pode me ajudar?
Quando eu declaro a classe na INT ela da o erro
<?php
require_once '../DTO/falecimentoDTO.php';
require_once '../CTR/falecimentoCTR.php';
require_once '../CTR/materiaCTR.php';
$dados = new falecimentoDTO();>
Quando eu declaro a classe na INT ela da o erro
<?php
require_once '../DTO/falecimentoDTO.php';
require_once '../CTR/falecimentoCTR.php';
require_once '../CTR/materiaCTR.php';
$dados = new falecimentoDTO();
É estranho o erro ser nessa linha exata. Eu acho que da erro quando você da o include_once nesse arquivo DTO.
Teste deixando apenas os includes na página, veja o que dá, e depois teste adicionando essa linha vermelha, acho que o erro vai dar as duas vezes, ou seja o erro não é nessa linha pois ocorre mesmo quando você remove ela.
Engraçado fiz o seguinte teste:
removi tudo e só deixei assim
<?php
require_once '../DTO/falecimentoDTO.php';
E não deu erro nenhum
porem quanto eu adcionei a linha de baixo e o codigo ficou assim
<?php
require_once '../DTO/falecimentoDTO.php';
require_once '../CTR/falecimentoCTR.php';
o erro aparece de novo.
se eu removo a classe CTR Ele não da pau.
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of falecimentoCTR
*
* @author MARKETING
*/
require_once '../DTO/falecimentoDTO.php';
require_once '../DAO/falecimentoDAOIMP.php';
class falecimentoCTR {
public function modificarFalecimento(falecimentoDTO $falecimentoDTO) {
try {
$falecimentoDAO = new falecimentoDAOIMP();
return $falecimentoDAO->modicicarFalecimento($falecimentoDTO);
} catch (Exception $exc) {
echo $exc->getMessage();
}
}
public function pesquisarFalecimento(falecimentoDTO $falecimentoDTO) {
try {
$falecimentoDAO = new falecimentoDAOIMP();
return $falecimentoDAO->pesquisarFalecimento($falecimentoDTO);
} catch (Exception $exc) {
echo $exc->getMessage();
}
}
}De duas uma, ou você está requerindo a classe 2 vezes em locais diferentes e não está utilizando o require_once/include_once ou você possui 2 classes com o mesmo nome.
Verifique o comando na sua IDE/Editor de texto para percorrer o projeto em busca de algo e procure pelo nome da classe para tentar descobrir o problema.
achei o erro.
Era um require perdido na minha interface falecimento.
Já fez uma buscar por "falecimentoDTO", para certificar de que não tem outra classe já criada?
Ou então por "falecimentoDTO.php", para ver se ela está sendo incluída sem o require/include_once?