The phrase function isn’t called at run time. It is called at compilation time.
If you look at your compiled templates you will see that templates are compiled for every style and language compilation. So the text for each phrase is essentially hard coded into the compiled template.
@Chris D thanks for your response what i want to do for example if i create a phrase with name "test" and its value is "example" so i want when page will load i want its value should be "1234" i want to do it via addon please let me know how i can do this ?
I deliberately didn't mention that simply because we explicitly advise against it in the code:
PHP:
// We do not recommend trying to extend this class or the tags/functions it defines. Doing so may interfere
// with the upgrade process. If you must do so, it should not be part of an add-on. It should be done
// unconditionally via config.php. However, do so at your own peril as the worst case would potentially be
// an un-upgradeable installation.
I feel like you already know this as you specifically mention that you wouldn't use it in an add-on
Honestly I'd just avoid extending that in absolutely all contexts.