Hallo,
ich bin PHP Einsteiger und verstehe grad nicht mehr warum unterer Code den Fehler "Invalid argument supplied for foreach() ..." erzeugt. ich möchte eigentlich nur Logs/Meldungen aus verschiedenen Scripten sammeln und am Schluß ausgeben! Ich dachte da könnte ich mir eine zentrale Stelle bauen, aber irgendwie will das nicht :( ... Hat jemand Rat?
<?php
global $logs;
function addLog($log) {
$logs[] = $log;
}
function printLogs() {
foreach ($logs as $log) {
echo 'Log :: ' .$log;
}
}
addLog('PALIM PALIM');
printLogs();
?>