如何在不制作大量PHP文件的情况下制作多个产品或新闻网站

i was thinking, regular site have just few subpages like:

-home
-about
-contact

And things like that, so in general you usually get below 10 .php files, but what if somebdy want to make CMS which generate new site for each news, right it is possible to make new php file for each of it but its unproductive.

I also find a way that i can just make something like "yourdomain.com/news/index.php?id=24" and just get data from mysql where ID = 24 but i need to display name of news in URL

So my question is how to make something like speciic URL for each news for example: www.yourdomain.com/news/name-of-new without making tons of php files and with specific description, keyword for each of them

The best answer here is to adopt a MVC programming method with one entry point that you define. Let me show a very basic example that will not involve using a pre-made framework. Basically you will have one entry point (usually the index.php file) and then for the most basic example one folder with modules for each page. You have to program the index.php so that according to a parameter it will load the correct page file. So far this is just what you suggested with the ?id=27 thingy.

Now let's make it a little piper. Create a .htaccess file next to your index.php one. A .htaccess file can define rules for your whole website. Here you need to make some rewrite rules. A rewrite rule is basically something that will tell your website to act like if the user asked index.php?id=27 whereas he asked yourdomain.com/news

So type first this code to enable the rewrite rule engine

RewriteEngine On
RewriteBase /

Then make a simple rewrite rule like this one

RewriteRule ^/(.*)$ /index.php?page=$1 [L]

Please keep in mind that you must use relative links otherwise this so far implicit redirection will show up in the browser nav bar.

There is a plenty of way to make rewrite rules, check Htaccess rewrite rule on the internet to find one that suits to your architecture.

EDIT: for preventing your rewrite rule to run when the requested url is a file (like an image) use these directives before the rewrite rule line

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d