Method: First write the css style code in a ".css" file; then in the PHP file, use "echo '';" statement can be called.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
PHP scripts can also call css styles Yes, we can use the echo statement to call the CSS style
First write the css style code in a ".css" file, such as theme.css; then use the following statement to call it
<?php echo ‘<link rel=\"stylesheet\" type=\"text/css\" href=\"theme.css\" />'; ?>
Benefits of calling css style sheets from outside the php page:
The web page processing speed will be faster, especially when there are many web pages sharing a CSS style sheet. ! Because you don’t have to write the same CSS code for every page, the web page will naturally be slimmer and lighter.
It can prevent some users with low computer skills from directly seeing CSS syntax (that is, some people don’t like to be seen). Of course, it means that they cannot see it directly, not that they cannot see it. As you can see, with a little bit of skill, it’s really easy to view the content of a CSS file.
Of course it is easy to maintain! As long as you modify one CSS file, no matter if you have thousands of web page files, your latest modified version will prevail!
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to call css in php. For more information, please follow other related articles on the PHP Chinese website!