如何从php中隔离样式(css + html)

how can i isolate the style (+) from , like put in the php file just some lines including by it the whole or theme.

ex:

echo 
    eval_template("header") .
    eval_template("body") .
    eval_template("footer")

So in future i can change the whole style without touch the php files any idea ?

there are many ways how you could do this...

Here's a tutorial on templating in plain PHP http://www.phpro.org/tutorials/Introduction-to-PHP-templating.html

You can also take a look at the many template engines out there. twig is one of them: http://twig.sensiolabs.org/

Personally, I enjoy to do it manually.

PHP should not return both css and html code, or even better, it shoukd not return client-side code at all but rather dependencies to specific parts. You never want to modify a file that contains a lot of different things.

To separate css+html from the php code, what I usually do is a hierarchy done with include("..."); and include_once("..."). For example : include_once("header.php") > include("menu.php") > html semantic with css classes correctly initialized according to current context.

Then you import your css / js external scripts in header.php so that you never have to modify the whole thing unless everything changes or if you have a complete feature to add to the website. Same is possible for every sections of the website.

Hope this helps, for me it is incredibly reducing debug-time since everything important has to be done only once, then at the top of it, you can seperate as you wish.

There are a lot of template engines you can use to do that, i prefer use twig, that is integrated with symfony2 framework.

Twig is wonderful because is very easy to use and very flexible, you can use inheritance to create a common layout which can be extended and overwriten in some some part using special tags. This is a guide i've find on Symfony website but is very usefull to understand the logic behind twig: http://symfony.com/doc/current/book/templating.html