PHP
Aus Doku-Wiki
Zur Navigation springenZur Suche springenInhaltsverzeichnis
Doku und Hilfeseiten
Datumsangabe in PHP anpassen
- In PHP kann diese Einstellung Systemweit in der php.ini angepasst werden
- oder direkt im Script mit
<?php setlocale(LC_TIME, 'de_DE.iso885915@euro'); echo date("l dS of F Y h:i:s A"); ?>
- Testzeile um die Asgabe zu testen
<?php echo date("l dS of F Y h:i:s A"); ?>
Ausgabe in Datei schreiben
$ft = @fopen('/tmp/templog', 'a+') or die("Kann Datei /tmp/templog nicht öffnen\n"); fwrite($ft, $commandLine); fclose ($ft);
a+ schreibt anhängend w schreibt neu
IP Range vergleichen
if (strpos($_SERVER['REMOTE_ADDR'],"10.10.") !== false) { tu was; } else { tu was anderes;
Error Reporting Manual
Im PHP-File
// Error Reporting komplett abschalten error_reporting(0); // Nur einfache Fehler melden error_reporting(E_ERROR | E_WARNING | E_PARSE); // E_NOTICE ist sinnvoll um uninitialisierte oder // falsch geschriebene Variablen zu entdecken error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Melde alle Fehler außer E_NOTICE // Dies ist der Vorgabewert in php.ini error_reporting(E_ALL ^ E_NOTICE); // Melde alle PHP Fehler error_reporting(E_ALL); // Dies entspricht error_reporting(E_ALL); ini_set('error_reporting', E_ALL);
In der php.ini
; Error handling and logging ; /etc/php5/apache2/php.ini
; error_reporting is a bit-field. Or each number up to get desired error ; reporting level ; E_ALL - All errors and warnings (doesn't include E_STRICT) ; E_ERROR - fatal run-time errors ; E_RECOVERABLE_ERROR - almost fatal run-time errors ; E_WARNING - run-time warnings (non-fatal errors) ; E_PARSE - compile-time parse errors ; E_NOTICE - run-time notices (these are warnings which often result ; from a bug in your code, but it's possible that it was ; intentional (e.g., using an uninitialized variable and ; relying on the fact it's automatically initialized to an ; empty string) ; E_STRICT - run-time notices, enable to have PHP suggest changes ; to your code which will ensure the best interoperability ; and forward compatibility of your code ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's ; initial startup ; E_COMPILE_ERROR - fatal compile-time errors ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) ; E_USER_ERROR - user-generated error message ; E_USER_WARNING - user-generated warning message ; E_USER_NOTICE - user-generated notice message ; ; Examples: ; ; - Show all errors, except for notices and coding standards warnings ; ;error_reporting = E_ALL & ~E_NOTICE ; ; - Show all errors, except for notices ; ;error_reporting = E_ALL & ~E_NOTICE | E_STRICT ; ; - Show only errors ; ;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR ; ; - Show all errors except for notices and coding standards warnings ; ;error_reporting = E_ALL & ~E_NOTICE error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
Session Timeout
In der Datei /etc/php5/apache/php.ini wird mit folgendem Parameter der Wert verändert werden:
O-Link
max_execution_time
Shibboleth Attribute in PHP verwenden
<html><head><title></title></head> <body> <?php $user = $_SERVER['uid']; $mail = $_SERVER['mail']; $vona = $_SERVER['givenName']; $nana = $_SERVER['sn']; $name = $_SERVER['cn']; echo "uid = $user <br />"; echo "mail = $mail <br />"; echo "Vorname = $vona <br />"; echo "Nachname = $nana <br />"; echo "oder Vorname, Nachname zusammen = $name <br />"; ?> </body> </html>