 |
| Hinweise |
Willkommen im TP-Hilfe-Forum!Dies ist ein Forum zu den Themen Photoshop, Dreamweaver, Flash, Selbständigkeit und mehr, in dem Du Hilfe, Anleitung oder eine Lösung zu Deinen Problemen erhältst. Aktuell bist Du in unseren Foren als Gast mit reinen Leserechten unterwegs. Wenn Du Dich registrierst, kannst Du eigene Themen verfassen, Deine Frage stellen und privat mit anderen TPlern kommunizieren. Weitere Foren werden zugänglich, und Du wirst – falls gewünscht – per Mail über neue Beiträge informiert. Die Registrierung ist schnell und kostenlos. Sollten bei der Registrierung Fragen auftauchen, reicht ein Klick in unsere Hilfe - Häufig gestellte Fragen oder eine kurze Mitteilung an das Support-Team. Viel Spaß bei Traum-Projekt.com |
25.02.2003, 16:28
|
#1
|
|
TP-Member
Registriert seit: Jul 2002
Ort: Pforzheim
|
verkettung von variablen
Hallo leutz,
ich bin zwar nicht so der coding-crack aber ich versuche mich an und wieder mit php.
Ich möchte mit php eine grafik erstellen, deren füllung und randfarbe immer harmonieren, sich aber bei jedem Seitenaufruf ändern.
Dazu hab ich mich unter anderem der funktion
rand (INT_MIN,INT_MAX) bedient.
Desweiteren habe ich mit imagecolorallocate 3 x 2 Farbpaare ( $col1 + $tex1 usw )die harmonieren definiert.
wie schaffe ich es das, ich wenn die funktion rand mir eine zahl. z.b 2 ausgibt ich diese mit der variable $tex UND $col verbinde, und entsprechend damit auch weiterarbeiten kann.
Am besten poste ich noch im anschluss meinen Quellcode.
Damit dürfte der eine oder andere was anfangen können.
Vielen Dank bis hierher
U
<?php
header ("Content-type: image/png");
$im = @ImageCreate (200, 100)
or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
$background_color = ImageColorAllocate ($im, 255, 255, 0);
$colrand = ImageColorAllocate ($im, 0, 0, 0);
$col1 = ImageColorAllocate ($im, 0, 0, 0);
$col2 = ImageColorAllocate ($im, 255, 212, 102);
$col3 = ImageColorAllocate ($im, 255, 255, 255);
$tex1 = ImageColorAllocate ($im, 255, 255, 255);
$tex2 = ImageColorAllocate ($im, 187, 160, 0);
$tex3 = ImageColorAllocate ($im, 0, 0, 0);
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$host = gethostbyaddr($ip);
$fw = rand (1,3)
$$colfw = "$col.$fw"
$$texfw = $tex.$fw
imagearc( $im, 7, 7, 16, 16, 180, 270, $colrand );
imagearc( $im, 191, 7, 16, 16, 270, 360, $colrand );
imagearc( $im, 7, 91, 16, 16, 90, 180, $colrand );
imagearc( $im, 191, 91, 16, 16, 0, 90, $colrand );
imageline ( $im, 8, 0, 190, 0, $colrand );
imageline ( $im, 199, 4, 199, 94, $colrand );
imageline ( $im, 194, 99, 4, 99, $colrand );
imageline ( $im, 0, 94, 0, 6, $colrand );
imagefill( $im, 3, 3,$ $colfw);
imagecolortransparent( $im, $background_color );
ImageString ($im, 2, 5, 20, " IP: ".$ip,$$texfw);
// ImageString ($im, 2, 5, 30, "HOST: ".$host, $text_color);
ImagePNG ($im);
?>
__________________
"der Einäugige ist unter den blinden König"
Meiner -> Dual XEON 3.06 GHZ, 2GB PC266 RAM
|
|
|
26.02.2003, 00:32
|
#2
|
|
TP-Member
Registriert seit: Jul 2002
Ort: Pforzheim
|
hmm keiner am start, der sich mit PHP / coding allgemein auskennt ??

__________________
"der Einäugige ist unter den blinden König"
Meiner -> Dual XEON 3.06 GHZ, 2GB PC266 RAM
|
|
|
26.02.2003, 14:34
|
#3
|
|
TP-Insider
Registriert seit: Jun 2001
Ort: Berlin
|
hilft dir das?
$fw = rand (1,3);
$col1 = "bild1";
$col2 = "bild2";
$col3 = "bild3";
$var_c = "col".$fw;
$$var_c; [inhalt der zB var $col1 ]
|
|
|
26.02.2003, 16:08
|
#4
|
|
TP-Member
Registriert seit: Jul 2002
Ort: Pforzheim
|
Hi Deck, danke für die Antwort, geht leider nicht .
Das Ding sieht jetzt so aus :
<?php
header ("Content-type: image/png");
$im = @ImageCreate (200, 100)
or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
$background_color = ImageColorAllocate ($im, 255, 255, 0);
$colrand = ImageColorAllocate ($im, 0, 0, 0);
$col1 = ImageColorAllocate ($im, 0, 0, 0);
$col2 = ImageColorAllocate ($im, 255, 212, 102);
$col3 = ImageColorAllocate ($im, 255, 255, 255);
$tex1 = ImageColorAllocate ($im, 255, 255, 255);
$tex2 = ImageColorAllocate ($im, 187, 160, 0);
$tex3 = ImageColorAllocate ($im, 0, 0, 0);
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$host = gethostbyaddr($ip);
$fw = rand (1,3)
$var_c = 'col'.$fw;
$var_t = "tex".$fw;
$$var_c;
$$var_t;
imagearc( $im, 7, 7, 16, 16, 180, 270, $colrand );
imagearc( $im, 191, 7, 16, 16, 270, 360, $colrand );
imagearc( $im, 7, 91, 16, 16, 90, 180, $colrand );
imagearc( $im, 191, 91, 16, 16, 0, 90, $colrand );
imageline ( $im, 8, 0, 190, 0, $colrand );
imageline ( $im, 199, 4, 199, 94, $colrand );
imageline ( $im, 194, 99, 4, 99, $colrand );
imageline ( $im, 0, 94, 0, 6, $colrand );
imagefill( $im, 3, 3,$ $var_c);
imagecolortransparent( $im, $background_color );
ImageString ($im, 2, 5, 20, " IP: ".$ip,$var_t);
// ImageString ($im, 2, 5, 30, "HOST: ".$host, $text_color);
ImagePNG ($im);
?>
Leider bringt er mir in line 24 nen Parse error.
Gruß
U
__________________
"der Einäugige ist unter den blinden König"
Meiner -> Dual XEON 3.06 GHZ, 2GB PC266 RAM
|
|
|
26.02.2003, 16:38
|
#5
|
|
TP-Insider
Registriert seit: Jun 2001
Ort: Berlin
|
erstmal fehlt hier
$fw = rand (1,3)
ein ; am ende.
musst du nicht unten die $$vars nehmen?
|
|
|
26.02.2003, 17:07
|
#6
|
|
TP-Member
Registriert seit: Jul 2002
Ort: Pforzheim
|
so gehts jetzt zumindest ohne Fehler
<?php
header ("Content-type: image/png");
$im = @ImageCreate (200, 100)
or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
$background_color = ImageColorAllocate ($im, 255, 255, 0);
$colrand = ImageColorAllocate ($im, 0, 0, 0);
$col1 = ImageColorAllocate ($im, 0, 0, 0);
$col2 = ImageColorAllocate ($im, 255, 212, 102);
$col3 = ImageColorAllocate ($im, 255, 255, 255);
$tex1 = ImageColorAllocate ($im, 255, 255, 255);
$tex2 = ImageColorAllocate ($im, 187, 160, 0);
$tex3 = ImageColorAllocate ($im, 0, 0, 0);
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$host = gethostbyaddr($ip);
$fw = rand (1,3);
$var_c = "col".$fw;
$var_t = "tex".$fw;
$$var_c;
$$var_t;
imagearc( $im, 7, 7, 16, 16, 180, 270, $colrand );
imagearc( $im, 191, 7, 16, 16, 270, 360, $colrand );
imagearc( $im, 7, 91, 16, 16, 90, 180, $colrand );
imagearc( $im, 191, 91, 16, 16, 0, 90, $colrand );
imageline ( $im, 8, 0, 190, 0, $colrand );
imageline ( $im, 199, 4, 199, 94, $colrand );
imageline ( $im, 194, 99, 4, 99, $colrand );
imageline ( $im, 0, 94, 0, 6, $colrand );
imagefill( $im, 3, 3,$ $$var_c);
imagecolortransparent( $im, $background_color );
// ImageString ($im, 2, 5, 20, " IP: ".$ip,$$var_t);
ImageString ($im, 2, 5, 20, $var_c." ".$$var_c." ".$var_t." ".$$var_t." ".$ip,$colrand);
// ImageString ($im, 2, 5, 30, "HOST: ".$host, $text_color);
ImagePNG ($im);
// echo $$var_c;.$$var_t
?>
bekomme als wert von $var_c z.b. col1 ausgegeben.. ich bräuchte aber $col1.
Any Ideas ??
__________________
"der Einäugige ist unter den blinden König"
Meiner -> Dual XEON 3.06 GHZ, 2GB PC266 RAM
|
|
|
26.02.2003, 17:26
|
#7
|
|
TP-Member
Registriert seit: Jul 2002
Ort: Pforzheim
|
<?php
header ("Content-type: image/png");
$im = @ImageCreate (200, 100)
or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
$background_color = ImageColorAllocate ($im, 255, 255, 0);
$colrand = ImageColorAllocate ($im, 0, 0, 0);
$col1 = ImageColorAllocate ($im, 0, 0, 0);
$col2 = ImageColorAllocate ($im, 255, 212, 102);
$col3 = ImageColorAllocate ($im, 255, 255, 255);
$tex1 = ImageColorAllocate ($im, 255, 255, 255);
$tex2 = ImageColorAllocate ($im, 187, 160, 0);
$tex3 = ImageColorAllocate ($im, 0, 0, 0);
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$host = gethostbyaddr($ip);
$fw = rand (1,3);
$var_c = "$"."col".$fw;
$var_t = "$"."tex".$fw;
$$var_c;
$$var_t;
imagearc( $im, 7, 7, 16, 16, 180, 270, $colrand );
imagearc( $im, 191, 7, 16, 16, 270, 360, $colrand );
imagearc( $im, 7, 91, 16, 16, 90, 180, $colrand );
imagearc( $im, 191, 91, 16, 16, 0, 90, $colrand );
imageline ( $im, 8, 0, 190, 0, $colrand );
imageline ( $im, 199, 4, 199, 94, $colrand );
imageline ( $im, 194, 99, 4, 99, $colrand );
imageline ( $im, 0, 94, 0, 6, $colrand );
imagefill( $im, 3, 3, $$var_c);
imagecolortransparent( $im, $background_color );
ImageString ($im, 2, 5, 20, $var_c." ".$var_t." ".$ip,$colrand);
ImagePNG ($im);
?>
jetzt bekomm ich zwar als wert von $var_c den Wert z.b. $col1
aber die füllfarbe ändert sich trotzdem nicht.
Ich riech´s schon.. wir sind kurz davor.... *schnüffel*
__________________
"der Einäugige ist unter den blinden König"
Meiner -> Dual XEON 3.06 GHZ, 2GB PC266 RAM
|
|
|
|
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
|
|
|
| Themen-Optionen |
Thema durchsuchen |
|
|
|
| Thema bewerten |
|
|
Forumregeln
|
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
HTML-Code ist aus.
|
|
|
Alle Zeitangaben in WEZ +2. Es ist jetzt 04:01 Uhr.
|
 |