SharkBait Posted June 1, 2006 Share Posted June 1, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/10963-global-variables/ Share on other sites More sharing options...
Ferenc Posted June 2, 2006 Share Posted June 2, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/10963-global-variables/#findComment-41159 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.