they work anywhere as long as you have it set up correctly.
the root declaration (docroot) is set in apache and not php. (in php too, but that doesn't have the same effect)
apache reads a file. if it ends in .php, it sends it to php to be parsed, then php sends it back. Nothing other than the extension matters. You can change what extensions are read in your apache conf file, though.