0
class department {
    function get($department,$info) {
        //do something
    }
}

class employment {
    function get($user_id,$info) {
        //do something
    }
}

$dept = new department();
$emp = new employment();

$dept->get($emp->get($_SESSION['i'],'dept'), "open");

I am trying to get the output variable from the $emp->get() function and put it into the $dept->get() function, but the output from $emp->get() is not processed by $dept->get().

How should I pass the value returned from $emp->get() to $dept->get()?

5
  • 1
    try var_dump($emp->get($_SESSION['i'],'dept')) and check if it returns something.. Commented Dec 27, 2012 at 4:00
  • Yes it returns something from the code including bool(true). Even echo works on the $emp->get() function, but once inside the $dept->get() function, it wont return the value Commented Dec 27, 2012 at 4:07
  • @ptewee can you show what is the result of var_dump($emp->get($_SESSION['i'],'dept')). Commented Dec 27, 2012 at 4:16
  • it returns: MANbool(true), MAN is the value i want to pass to the $dept->get(); function Commented Dec 27, 2012 at 4:20
  • echo $emp->get($_SESSION['i'],'dept'); gives me MAN Commented Dec 27, 2012 at 4:23

2 Answers 2

2

classes are not initialised like this

$dept = new $department();
$emp = new $employment();

the proper syntax is

$dept = new department;
$emp = new employment;

http://php.net/manual/en/language.oop5.php

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I hand wrote the question without copying direct from my code, so those were my mistakes. I've edited my question
0

Turned out the output from $emp->get() is an echo, not a return, so it wasn't accepted by $dept->get(). My mistake!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.