You're kind of discussing several different things at once, I think. There's obviously more than one way to build a site - you talk about using AJAX from index.php; you can also use rewrite rules from an index.php front-loader to dynamically route to a back-end controller, for example. In my experience, most modern web-based coding goes this route - Laravel, Symfony, Drupal, WordPress, CodeIgniter, etc... (I've not used Cake, but from what I've read it's the same paradigm). Now, on top of that you're talking about changing the entire site design easily - this can be done via CSS as dalecosp described, or it can be done using modular site template files, which is what I think you're actually asking about here.
Given that assumption, there are a ton of different templating solutions out there - personally, I prefer Twig, but there's also Blade, Mustache, heck - even Smarty is apparently still kicking. Run a Google search for PHP template engines and you can spend six days reading non-stop. And finally, you can just create plain HTML files with injected PHP code.
At any rate, the basic premise behind template engines is that you'll create one or two "base" or "parent" templates - typically these include the outer-most structural markup and include directives to other files, called "partials". Partials are HTML/template code bits and pieces that serve a specific purpose. For instance, you can have a parent page that lays out the open/close HTML, head, body, and footer tags. Within the head, it'll include a partial that actually lays out all the head meta-data. The body partial is dynamic and controlled by the framework depending on what page the user is on, or what data has been presented and processed by the system - this can also include other partial files. The footer contains any additional code - JavaScript includes, coda, etc.
The joy of doing things this way is that you can change one file - the base, or parent, template - and that change happens on every page in the site because they all extend from that base file. Or you can change a more specific file and that change will be scoped to the pages that use or include that partial.
At my last job, we worked a lot with WordPress. The WordPress way of "templating" is to create HTML files with PHP injected directly, and it's dumb. I hate it. So, I found a plugin that let us use Twig and I built a theme bootstrap. My personalized version of it is here. Take a look in the /wp-content/themes/theme-folder/views directory for Twig-based template files and how it's all laid out. You can also take a look at the /wp-content/themes/theme-folder/includes/Functions.php file for an idea of how the data gets from the WordPress database to the template files for output.
Well that was much longer than intended, and hopefully it makes some sort of sense!