Local variables in hook?

If I wanted to use a local variable defined in the same function as a hook is added, could I use that variable in the hook? If not, how could I?

I’m sorry that it’s so general and there is no example but I felt that it wasn’t necessary.

If the function is defined in the scope of the local variable, you can use it inside the function.

Thanks for your answer.