Including CSS in .php file

◇◆丶佛笑我妖孽 提交于 2019-12-10 12:27:38

问题


I am trying to include a css file to my .php file.

Inside the .php file, I have;

<?php
Loads of code..
?>

I'm wanting it like this..

<?php
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
Loads of code..
?>

But obviously that doesn't work. Is there any way I can do this?

Thanks!


回答1:


You can use echo..

<?php
echo '<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">';
?>



回答2:


<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<?php
Loads of code..
?>



回答3:


Uhhhm... You mean something likes this?

<?php
echo '<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">';
Loads of code..
?>



回答4:


I have posted a simple solution here : https://navydadon.wordpress.com/2016/02/18/css-in-php-file/ hope it will helps :)




回答5:


The same happened for me a long ago. The best way to solve this is by inserting the css files in all of the files you have included to make your main php page.



来源:https://stackoverflow.com/questions/15086785/including-css-in-php-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!