This isn't a PHP issue, but an HTML issue.
PHP gets parsed by the server, and outputs the processed HTML. So as long as anexample.html has an anchor tag with a matching name, and you link to #anchor-name, it should work.
If it's not working, I would take a look at what your processed HTML result looks like by doing a view > (page) source after loading your page. If it's still not working, post the relevant code and we'll take a look.
Hope this helps.