So you're using something like {xen:link threads, $thread} in a template?
If the $thread or some other variable is already available in a template then it is already available in PHP...
You might need to provide us with some template and PHP examples with this one..