Search code examples
phpapc

What does the $values parameter of apc_add() do?


http://php.net/apc_add

I don't understand what the $values parameter actually does - it is not even shown in function signature.

Can anybody help explain?


Solution

  • It's not a 4th parameter, rather an alternate first parameter. There are 2 ways of using apc_add().

    You can either set a single item by passing a key and value:

    apc_add('Key', 'Value');
    

    Or you can set multiple variables at the same time by passing them in an array:

    $data = array('Key1' => 'Value1', 'Key2' => 'Value2');
    apc_add($data);
    

    This is equivalent to doing:

    apc_add('Key1', 'Value1');
    apc_add('Key2', 'Value2');