Jump to content

Recommended Posts

I currently am using a php file 'stylesheet.php' that echos out a validated CSS content for my site.

 

I want to write the CSS content to a file 'stylesheet-public.css'.

 

I've tried: http://php.net/manual/en/function.eval.php

 

but it does not work since the PHP content has multiple opening and closing tags (<?php ?>).

 

Any other ideas?

the file name must end in .PHP (unless you add a type to the php engine)

and the script needs to know its contents type..

So you should end up with something like this

<?php
header('content-type:text/css');
echo "/*CSS CODE*/";

Why are you going this route again?  Do you have a database that populates a CSS file?  That is the only reason I can think of for using PHP to create a CSS file.

 

If you really want to do this.. instead of eval I would look into the file editing functions like fwrite, fread, fget, etc

Opps I did it again!

Ignore my first post.. I completely missed the question! (got it around the wrong way)

 

however.. another quick dirty option is

<?php
file_put_contents("stylesheet-public.css",file_read_contents("http://yourDomain.com/yourCSS.php"));

 

Now you must read from the HTTP address, this will read the file from apache instead of direct, this will then parse the file for you, as if you was a client

 

But as Zanus said.. why ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.