Jump to content


Create Css File in PHP

  • Please log in to reply
3 replies to this topic

#1 irperera

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 27 September 2006 - 11:30 PM

I'm creating a menu that uses css and mysql database. I have everything working, expect the fact that i need to go in manual and change or add css styles. what i would like to do is find out how to make php create a css file and input style where needed. can someone point me into the correct direction?


#2 ToonMariner

  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 28 September 2006 - 02:19 AM

You could set the href of you css in the link tag to a php script which would output css.


you could use php to edit the css file. To do this you will need file_get_contents and file_put contents (or the fopen fread fput fclose equivalnet) and to develop a method of finding the relevant lines in the css....
follow me on twitter @PHPsycho

#3 Ninjakreborn

  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 28 September 2006 - 10:41 PM

make a regular php file, and put it as
<a href="style.php" rel="stylesheet" type="text/css" />
it works perfectly if
1. you send a css header using php to the browser
2. you make sure everything that outputs from the php is valid css, same for javascript files.


Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.

#4 dustinnoe

  • Members
  • PipPipPip
  • Advanced Member
  • 187 posts
  • LocationWarner Robins, GA

Posted 13 October 2006 - 02:59 PM

You could just embed the CSS and use php to echo the styles.  Then you could pull from a database or SESSION.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users