将对象从函数传递到另一个函数

Here's the situation i'm passing a object through several php functions. I m looking for the best performance so i was wondering is serialization a good way to do it or is serialization not necessary?

If you are passing an object through several 'functions' then you don't need to serialise - this will be in memory in the PHP parser and serialization will just be a waste.

If you need to pass the value from one script page to another, then serialization is an option as the variables in the first script will be out of scope in the second script.

Most of the time you don't need to do this - what exactly are you trying to do?

Serialization is one of the worst things you can do. Objects in php 5 are passed by reference and this way the amount of data passed between functions is minimal(only a pointer which is an integer).

Just pass the object. You don't need serialization.

function foo() {
    return new Foo;
}

function bar($obj) {
    return $obj;
}

function baz($obj) {
    $obj->foo();
}

baz(bar(foo()));

I believe there is no problem passing objects around like this:

$obj=new myclass;
$result=mufunk($obj);

function myfunk($myfobj)
  {
    $myreturn=new anotherclass;
    return $myreturn;
  }