The function can help you answer this question. debug_zval_dump()
For example, if I ran the following code:
$str = 'test';
debug_zval_dump($str); // string(4) "test" refcount(2)
my_function($str);
debug_zval_dump($str); // string(4) "test" refcount(2)
function my_function($a) {
debug_zval_dump($a); // string(4) "test" refcount(4)
$plop = $a . 'glop';
debug_zval_dump($a); // string(4) "test" refcount(4)
$a = 'boom';
debug_zval_dump($a); // string(4) "boom" refcount(2)
}
I get the following output:
string(4) "test" refcount(2)
string(4) "test" refcount(4)
string(4) "test" refcount(4)
string(4) "boom" refcount(2)
string(4) "test" refcount(2)
So, I would say:
- "Refcounted" strings when passed to functions (and possibly when assigned to variables)
- BUT do not forget that PHP makes a copy when writing
For more information, here are some links that may be helpful: