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
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
Share on other sites

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.