Hello, can I pass on something?
<?php $color='red' ?> <link rel="stylesheet" href="link_css.css" > link_css.css p{color:<? echo $color ?>}
link_...">
Hello, can I pass on something?
<?php $color='red' ?> <link rel="stylesheet" href="link_css.css" > link_css.css p{color:<? echo $color ?>}
1 option. Use instead of the css-file php-file. Add a header to the top of the php file:
<?php header("Content-type: text/css"); ?>
It is connected as a normal css-file, not including:
<link rel="stylesheet" href="style.php" />
But. Does not work in IE.
Option 2. Process css-files as php. Add the following lines to your .htaccess file:
<Files style.css> ForceType application/x-httpd-php AddHandler application/x-httpd-php .css </Files>
The stype.css file will be processed as a PHP file . It is connected as usual:
<link rel="stylesheet" href="style.css" />
Most likely, you need this <p style="color:<?echo $color?>">Text...</p>
It would be more correct to use different classes, the names of which are substituted into the template using php
<p class="<?php echo $class;?>">Text...</p>
or with a certain logic:
<p class="<?php echo (условие) ? $class1 : $class2;?>">Text...</p>
Talk a topic started by @khvorostin . We connect the style with the color parameter
<link rel="stylesheet" href="link_css.css?color=red" >
and in link_css.css
p{color:<?=$_GET['color'];?>}
If there are not many such dynamic styles, you can add them directly to HTML through the style tag in the head section. Then it will not be necessary to process css files as php.
Source: https://ru.stackoverflow.com/questions/192525/
All Articles