[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: SV: [PROGRAMMERING] <form action="<?php echo $PHP_SELF?>" method="POST">



Lars Riisgaard Ribe wrote:
klip
<?php print("SERVER PHP_SELF =
$_SERVER['PHP_SELF']<br>");?> før

Her går det galt, da der ikke ekspanderes på array's i en string.

[klip]


Jo, det gør der faktisk, hvis man skriver <?php print("SERVER PHP_SELF =
$_SERVER[PHP_SELF]<br>");?>, altså uden apostrof eller citationstegn rundt
om PHP_SELF. Det undrer mig faktisk, at Jørgen ikke får fejl, når han
skriver det med apostrof.

Det er lidt ejendommeligt.
Se f.eks:
<?php print("A. SERVER PHP_SELF => " . $_SERVER['PHP_SELF'] . "<br>");?>
<?php print("A2. SERVER PHP_SELF => " . $_SERVER[PHP_SELF] . "<br>");?>
<?php print("B. SERVER PHP_SELF => {$_SERVER['PHP_SELF']}<br>");?>
<?php print("B2. SERVER PHP_SELF => {$_SERVER[PHP_SELF]}<br>");?>
<?php print("C. SERVER PHP_SELF = $_SERVER['PHP_SELF']<br>");?>
<?php print("C2. SERVER PHP_SELF = $_SERVER[PHP_SELF]<br>");?>

Både A, A2, B, B2 og C2 viser værdien af PHP_SELF, men C er blank.

Brugen af apostrof svarer sikkert til brugen af apostrof ved filnavne.
Består et filnavn af flere ord skal der sættes apostrof om når der refereres til navnet.
Eksempel:
ls 'fil navn'
Et filnavn i 'et ord skal ikke omgives af apostroffer, men det skader ikke.
Eksempel:
ls 'filnavn'
giver samme resultat som
ls filnavn


Man kan så spekulere på, hvorfor brugen af '' i tilfældet PHP_SELF ikke altid er valgfri, men det skyldes måske at $_SERVER formentlig ikke er et array, man snarere er en class, altså en qualifier til navnet PHP_SELF. Kun i tilfælde C og C2 opfattes $_SERVER som et array, og PHP_SELF som et indeks.
OK, der er måske noget vrøvl, men giver dog en slags forklaring.



-- Med venlig hilsen

Jørgen Heesche
mailto:sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *