[SOLVED] Problem with OOP.
Posted: Wed Jul 22, 2009 7:57 am
Hi guys, 1st post here, im a little noob with oop on php, but not too much.
I´m using an object, and writing in a array inside other object. The problem is, when i have more than 1 call to object input without renew, even using an array inside the object who is inheriting the object, it just maintein the last value i insert inside it.
i am using like this
the output for example is:
evento
evento
I need the output like this.
cliente
evento
I already know how it works ok, if i use the code below, but i do not want to create hundreds of times the object input.
Here´s my problem. There´s anyway i could do something like this on php?
or to instantiate a new object like this
Some like that could solve my problem, but like what i'm doing, php crashes miserably.
If anyone of you guys have a good recomendation of php opp lecture, i would be glad 2
Thanx 4 ur attention.
I´m using an object, and writing in a array inside other object. The problem is, when i have more than 1 call to object input without renew, even using an array inside the object who is inheriting the object, it just maintein the last value i insert inside it.
Code: Select all
private input = array();
public function setInput($input) {
$this->input[] = $input;
}
Code: Select all
$input = new input();
$form->setInput($input->getArraySelect('cliente', $clientes, $cliente, $erro['cliente']));
$form->setInput($input->getArraySelect('evento', $eventos, $evento, $erro['evento']));evento
evento
I need the output like this.
cliente
evento
I already know how it works ok, if i use the code below, but i do not want to create hundreds of times the object input.
Code: Select all
$input = new input();
$form->setInput($input->getArraySelect('cliente', $clientes, $cliente, $erro['cliente']));
$input = new input();
$form->setInput($input->getArraySelect('evento', $eventos, $evento, $erro['evento']));
Code: Select all
class object () {
//this function might receive a new object
function setObject($object) {
if (is_object($input) && $this != $input) {
$this = $input;
}
}
Code: Select all
$form->setInput(new input()->getArraySelect('cliente', $clientes, $cliente, $erro['cliente']));
$form->setInput(new input()->getArraySelect('evento', $eventos, $evento, $erro['evento']));
If anyone of you guys have a good recomendation of php opp lecture, i would be glad 2
Thanx 4 ur attention.