Jump to content

Including an External CSS Stylesheet in PHP

- - - - -

  • Please log in to reply
2 replies to this topic

#1
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 298 posts
  • Location:Australia
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly
Hello all,

I want to know how to link to an external CSS stylesheet using PHP, on a conditional basis.

For example:


if ($cssOption == "default")

{

     //Include external CSS stylesheet...

}


I've seen some similar, but not exactly this.

Thank you for any help...

Edited by Hunter100, 22 April 2011 - 02:57 AM.

Jack
Creator, Owner, Webmaster
Brezerd.net

#2
liamzebedee

liamzebedee

    Programmer

  • Members
  • PipPipPipPip
  • 129 posts
You could reference this later in your code. For example-
<?

if ($cssOption = "default")

{

defaultCss = true;

}

//.........later

?>

<head>

<?

if (!defaultCss)

{

echo "<LINK REL=StyleSheet HREF=\"style.php\" TYPE=\"text/css\" MEDIA=screen>"

}

else{//link default stylesheet}

?>

</head>

Then you could edit style.php to get the users custom style from a database and echo it in a CSS format.

#3
RHochstenbach

RHochstenbach

    Learning Programmer

  • Members
  • PipPipPip
  • 56 posts
PHP will first execute all commands, and then sends it to the browser as an HTML file. You can have PHP build the entire HTML code on a conditional basis if necessary ;)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users