AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

[PHP] Globale Variablen

Ein Thema von 3_of_8 · begonnen am 3. Jun 2006 · letzter Beitrag vom 3. Jun 2006
Antwort Antwort
Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#1

[PHP] Globale Variablen

  Alt 3. Jun 2006, 01:31
Morgen.

Noch ein Problem mit PHP.

Ich habe grade folgendes probiert:

Code:
global $blubb;

function foo() {
$blubb["abc"]="wuppdi";
}

function bar() {
echo($blubb["abc"]);
}

foo();
bar();
Was bekomme ich? Natürlich eine leere Ausgabe. Wäre sonst auch zu leicht gewesen.

Was mache ich da falsch? Welche Einstellung verbockt das?

Wenn ich statt $blubb["abc"] schreibe $GLOBALS["blubb"]["abc"] geht es seltsamerweise.
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat
Benutzerbild von titus
titus

Registriert seit: 5. Apr 2004
Ort: Freiburg
232 Beiträge
 
#2

Re: [PHP] Globale Variablen

  Alt 3. Jun 2006, 01:44
Es muss heißen:
Code:
function foo() {
  global $blubb;
  $blubb["abc"]="wuppdi";
}

function bar() {
  global $blubb;
  echo($blubb["abc"]);
}

foo();
bar();
Die Variable wird nicht als global "markiert"/gesetzt, sondern in der Funktion als global angesehen (so in etwa).

Zitat:
Wenn ich statt $blubb["abc"] schreibe $GLOBALS["blubb"]["abc"] geht es seltsamerweise.
Ist auch klar:
Die Variable wird in dem Fall als global "markiert"/gesetzt.

mfG, titus
Daniel L.
'-'
  Mit Zitat antworten Zitat
Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: [PHP] Globale Variablen

  Alt 3. Jun 2006, 09:44
Aaah... Klingt fast logisch.

Danke.
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat
Antwort Antwort


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.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz