Re: php instead css styles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Whenever I need to do dynamic cssI would do so by naming the file:

style.css.php

Then I can do something like:

---------------------------------------------
<?php
require_once('user_info.php');
header("Content-type: text/css");
?>
.user-<?=$uer_id;?> {
     background-color: red;
}
--------------------------------------------

Which I then include normally:

<link type="text/css" rel="stylesheet" href="style.css.php" />

On Mon, Feb 15, 2021 at 8:36 AM David Spector <david025@xxxxxxxxxxxxxxxxxxxxxx> wrote:
Dear Muhamad,

Yes, many web-related file operations can be done in PHP easily, using
functions like file_get_contents and file_put_contents. See the PHP
Manual and search the web to answer such basic questions.

In this case, read in the two styles files, then concatenate them into a
single string and write out that string. Your HTML file can then link to
that new file instead of to the two style files.

David Spector/Springtime Software

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux