openlog()
openlog() — Open connection to system logger.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
openlog() opens a connection to the system logger for a program.
Signature
openlog(string $prefix, int $flags, int $facility): true
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $prefix | string | The string prefix is added to each message. |
| $flags | int | Bitmask of the following constants: LOG_CONS LOG_NDELAY LOG_ODELAY LOG_NOWAIT LOG_PERROR LOG_PID |
| $facility | int | The facility argument is used to specify what type of program is logging the message. This lets the configuration file specify that messages from different facilities will be handled differently. Must be one of the following constants: LOG_AUTH LOG_AUTHPRIV LOG_CRON LOG_DAEMON LOG_KERN LOG_LOCAL[0-7] LOG_LPR LOG_MAIL LOG_NEWS LOG_SYSLOG LOG_USER LOG_UUCP |
Return value
Always returns true.
Example
The PHP manual ships no example for openlog(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.2.0 | The function now always returns true. Previously it returned false on failure. |
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page openlog() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.