WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   php global definitionen geht nicht ? (http://www.wcm.at/forum/showthread.php?t=74580)

MZ 24.10.2002 15:22

php global definitionen geht nicht ?
 
ganz oben hab ich:

global $bgcolor7

dann:

$bgcolor7 = "#FF9933"; //die farbe definiert

und irgendwo in einer funktion ruf ich dann auf:

echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" bgcolor=\"$bgcolor7\">\n"... usw...

nur er nimmt mit die farbe nicht.

Wenn ich aber statt $bgcolor7 den farbwert #ff9933 einsetze geht es.

WARUM ?

Philipp 24.10.2002 18:03

PHP-Code:

global $bgcolor7

musst du nach
PHP-Code:

function name() { 

verwenden und nicht am Anfang des Scripts :)

MZ 25.10.2002 08:19

klingt zwar unlogisch (und bei allen anderen definitionen gehts auch) aber ich habs probiert - ohne Erfolg.

käptn 25.10.2002 10:33

PHP-Code:

$bgcolor '#AAAACC';

function 
echo_td($cellcontent) {
     global 
$bgcolor;
     echo 
'<td bgcolor="'.$bgcolor.'">'.$cellcontent.'</td>';


Geht net - gibt's net :D

~

_m3 25.10.2002 11:18

http://at.php.net/manual/de/migration4.variables.php
Zitat:

While handling of global variables had the focus on to be easy in PHP 3 and early versions of PHP 4, the focus has changed to be more secure. While in PHP 3 the following example worked fine, in PHP 4 it has to be unset($GLOBALS["id"]);. This is only one issue of global variable handling. You should always have used $GLOBALS, with newer versions of PHP 4 you are forced to do so in most cases. Read more on this subject in the global references section.
PHP-Code:

<?php
$id 
1;
function 
test()
{
    global 
$id;
    unset(
$id);
}
test();
echo(
$id); // This will print out 1 in PHP 4
?>



MZ 28.10.2002 13:45

ich will sie aber nicht unsetten weil ich die variablen später wieder benötige.

Philipp 28.10.2002 15:04

Poste vielleicht einmal das ganze Script

MZ 28.10.2002 15:31

hehe lieber nicht aber ich werd mal a bisl war rauskopieren

PHP-Code:

<?php
$tabbgcolor 
=   "#FFFFFF"
$tabcolor =     "#8F9CAC"
$tabbgcolor2 =  "#AAAAAA";
$tabcolor2 =    "#BBBBBB";
$headercolor =  "#FF9933"
$menuebgcolor "#F4F7E5";
$textcolor1 =   "#FFFFFF";  
$textcolor2 =   "#0066CC"
$textcolor3 =   "#000000";  
$footercolor =  "#FFFFFF"
$titlecolor =   "#FFFFFF";
function 
themeheader() {
global 
$user$banners$sitename$slogan$cookie$prefix$tabbgcolor$headercolor$textcolor1$textcolor3;
    
cookiedecode($user);
$username $cookie[1];
//
//(hier noch ein paar unterfunktionen)
//
echo "<body topmargin=\"0\" leftmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" bgcolor=\"$tabbgcolor\">\n\n";  //HIER ZB DIE TABBGCOLOR GEHT NICHT

echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"1\" bgcolor=\"$headercolor\">\n"  //HIER ZB DIE HEADERCOLOR GEHT NICHT
."<tr>\n"
."<td align=\"left\" valign=\"bottom\" width=\"65%\"><a href=\"index.php\"><img src=\"themes/TPLUS/images/tplus_bo.jpg\" align=\"left\" alt=\""._WELCOMETO." $sitename\" border=\"0\"></a>[b]<h2>text</h2>[/b]</td>\n"
."<form action=\"modules.php?name=Search\" method=\"post\">\n"
."<td align=\"right\" valign=\"bottom\">\n"
."<font class=\"content\" color=\"$textcolor3\">[b]".translate("Seite durchsuchen")." [/b]\n"
."<input type=\"text\" name=\"query\" size=\"14\"></font></td></form>\n"
."</tr></table>\n"
."<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\" align=\"center\">\n"
."<tr valign=\"middle\" bgcolor=\"#ffffff\">\n"
."<td align=\"left\" valign=\"top\" width=\"8\" height=\"22\" background=\"themes/TPLUS/images/topnav-bg.gif\"></td>\n"
."<td width=\"15%\" background=\"themes/TPLUS/images/topnav-bg.gif\" nowrap><font class=\"content\" color=\"#363636\">\n";
//weiter in der funktion
}

im Quelltext sieht das dann so aus:
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="">

<table cellpadding="0" cellspacing="0" width="100%" border="1" bgcolor="">

Philipp 28.10.2002 15:59

Das Script selber funktioniert hier problemlos

Wie wird es eigentlich aufgerufen? Sieht für mich wie ein Skin für PHP-Nuke aus ;)

MZ 28.10.2002 16:07

ja ist ein theme für phpnuke 6

Philipp 28.10.2002 20:23

Das neue PHP-Nuke 6.0 habe ich mir nicht angesehen da ich derzeit ohnehin mein eigenes CMS schreibe ;)

Ich würde eventuell die Werte direkt im HTML Code einbauen.


Alle Zeitangaben in WEZ +2. Es ist jetzt 11:02 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag