I want to include my css file in php can someone help me how to add ?
include('config.php');
$cssFile = "style.css";
echo "<link rel='stylesheet' href='/books/style.css'>";
How to add my css in PHP application?
I want to include my css file in php can someone help me how to add ?
include('config.php');
$cssFile = "style.css";
echo "<link rel='stylesheet' href='/books/style.css'>";
How to add my css in PHP application?
Considering your PHP starts with <?php or <? tags, you can add the CSS to the top of your php file (or after some lines if you are sending headers though php) out of the php tags.
Dont forget that styling applies to HTML code, so it needs to be out of PHP. If your PHP produces html code, you can use normal CSS there too.
Example :
<html>
<head>
<link rel='stylesheet' href='/books/style.css' type="text/css">
</head>
<body>
<?php
include('config.php');
//your php code here
?>
</body>
</html>
Asked and answered already. Please make sure to search Google first. I found many tutorials and answers already out there :). I like this one the best: https://stackoverflow.com/a/6315792/1015712.
Full question and answer here: How to import/include a CSS file using PHP code and not HTML code?
It was 6 years ago, but I don't think newer PHP versions have change this.