示例#1
0
                    $this->_logfile_name = $param;
                }
                $this->_logfile = @fopen($this->_logfile_name, 'a+');
                if ($this->_logfile == false) {
                    $this->fatal('Failed to open ' . $this->_logfile_name . ' for writing');
                }
                return false;
            default:
                // Unrecognized
                $this->fatal('Unrecognized command line switch: ' . $switch);
                break;
        }
        return false;
    }
}
$DAEMON = new ChatDaemon();
set_error_handler(array($DAEMON, 'error_handler'));
/// Check the parameters //////////////////////////////////////////////////////
unset($argv[0]);
$commandline = implode(' ', $argv);
if (strpos($commandline, '-') === false) {
    if (!empty($commandline)) {
        // We cannot have received any meaningful parameters
        $DAEMON->fatal('Garbage in command line');
    }
} else {
    // Parse command line
    $switches = preg_split('/(-{1,2}[a-zA-Z]+) */', $commandline, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
    // Taking advantage of the fact that $switches is indexed with incrementing numeric keys
    // We will be using that to pass additional information to those switches who need it
    $numswitches = count($switches);