Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problem mit $PHP_SELF / $_SERVER['PHP_SELF']

Empfohlene Antworten

Veröffentlicht

Hi,

hab mir ein Script gebastelt, was immer das aktuelle Datum der letzten Änderung einer Datei angibt. Wenn ich die Datei im Quelltext angebe, funktionierts ohne Probleme. Nutze ich jedoch die Variable $PHP_SELF, findet er gar keine Datei und mit $_SERVER['PHP_SELF'] fehlt ein Punkt vor dem Pfad => findet die Datei auch nicht.

Weiss jemand, wie man das in den Griff bekommt, oder muss man den Punkt da echt jedesmal dann noch manuell hinzufügen im Quelltext? :confused:

Habs momentan jetzt so:


<?php
$file =".".$_SERVER['PHP_SELF']
$filetime = filemtime($file);
$lastupdate = date("d.m.Y H:i:s", $filetime);
echo "Letztes Update der Seite vom :".$lastupdate.".<br>";
?>
[/PHP]

[edit]

Wenn ich mir die Variable $_SERVER['PHP_SELF'] in der Datei test.php ausgeben lasse, kommt einfach nur "/test.php" dabei raus. Müsste aber eigentlich "./test.php" oder "test.php" lauten, damit die Pfade stimmen.

[/edit]

'PHP_SELF'

The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.

Ist also Korrekt. Was du eigentlich willst ist __FILE__

  • Autor
[...]__FILE__ The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances.[...]
Den Filenamen der Datei die ich include will ich ja nicht haben, sondern schon den Namen der Datei, in der ich die andere Datei include. :rolleyes:

Oder hab ich das falsch verstanden? :confused:

Nein. Wenn du includest, könnte vielleicht $_SERVER["SCRIPT_FILENAME"] was für dich sein.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.