PHP in CSS file |
[eluser]Kemik[/eluser]
Hey all, This is a bit of a noob question but if I put php in a css file and load the css file as normal will the php run? Code: #middle_banner{ PHP's rand() function would be great to select a random middle_banner. I was going to do middle_banner_<?php rand(2, 6) ?>.jpg Thanks.
[eluser]daulex[/eluser]
found this on the net Quote:I guess php tags were not being processed because the webserver did not associate a .css file with the php script engine.
[eluser]Tom Glover[/eluser]
[quote author="daulex" date="1213747249"]found this on the net Quote:I guess php tags were not being processed because the webserver did not associate a .css file with the php script engine.[/quote] Remember php ignores any other code in a file that is not wrapped in php tags.
[eluser]Kemik[/eluser]
I tried changing the extension to php before I opened this topic as it seemed common sence. Apparently you need to add some header and content type info to the top of the css file, which I originally missed.
[eluser]Wilbur Himself[/eluser]
you can do it, you must have the file with a .php extension, and you must set a header like: header('Content-type: text/css');
[eluser]John_Betong[/eluser]
Hi Kemik, >>> PHP’s rand() function would be great to select a random middle_banner. >>> I was going to do middle_banner_<?php rand(2, 6) ?>.jpg I recently introduced this code so that the 1676x76px smiley banner starts at a different position each time the page is loaded. Code: <body> You can see it here |
Welcome Guest, Not a member yet? Register Sign In |