I want to override predefined template file in my extension.How to do that using php?
Hardcoding cusomised templates into extensions is in breach of extension development standards and can break on upgrades. Prevention of errors is an important priority to most developers to take pride in their craft and care about their clients.
The answer in your extension is to include the modified file in the path form template/CRM/path/to/template.tpl.php - but please find a better way. Civi users deserve great products that they get from other services, not this.
You can use hook_civicrm_alterTemplateFile to select a different template file - but beware of the problems of overriding templates.