Jump to content

Global Variables


SharkBait

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/10963-global-variables/
Share on other sites

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

[code]$style = "template/style_1.css";

include "template/header.php";
[/code]

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

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

[code]<head>
<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" />
</head>[/code]
Link to comment
https://forums.phpfreaks.com/topic/10963-global-variables/#findComment-41159
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.