Jump to content


Global Variables

  • Please log in to reply
1 reply to this topic

#1 SharkBait

  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 01 June 2006 - 03:03 PM

Is there a proper way to use Global Variables in PHP? I have registered_globals turned off in my php.ini file, but isnt there a $_GLOBALS[] or something?

I think my issue with this thread: [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=93787&hl=\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...topic=93787&hl=[/a]
is the fact that my CSS file does not see the style variable I am setting before I require() or Include() the header.html file an thus not allow me to make CSS additions with PHP on a per page basis.

Hopefully this makes sense.. I would hate to have gigantic thousand line CSS pages, and keeping track of them all wouldnt be that easy.

I change formattings of div tags etc depending on the content I need to display, so being able to set CSS variables before I call my header.html file (that links to the actual CSS file) would be great.

#2 Ferenc

  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts

Posted 02 June 2006 - 01:41 PM

You have to set, or define a variable before you want to use it.

$style = "template/style_1.css";

include "template/header.php";

The easiest way would be to have all css in one sheet...

Then you can use any class after the header is included.

<title>My Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="<?php echo $style; ?>" rel="stylesheet" type="text/css" />

Everything you want to know is here.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users