PHP.nl

dio_open

dio_open

Opens a file (creating it if necessary) at a lower level than the C library input/ouput stream functions allow

resource **dio_open** string $filename int $flags int $mode
opens a file and returns a new file

descriptor for it.
dio_open

filenameThe pathname of the file to open.

flags The parameter is a bitwise-ORed value comprising flags from the following list. This value include one of , , or . Additionally, it may include any combination of the other flags from this list.

  `flags`*must*`O_RDONLY``O_WRONLY``O_RDWR`- - opens the file for read access.          `O_RDONLY`
    • opens the file for write access. O_WRONLY
    • opens the file for both reading and writing. O_RDWR
    • creates the file, if it doesn't already exist. O_CREAT
    • if both and are set and the file already exists, will fail. O_EXCL``O_CREAT``O_EXCL``dio_open
    • if the file exists and is opened for write access, the file will be truncated to zero length. O_TRUNC
    • write operations write data at the end of the file. O_APPEND
    • sets non blocking mode. O_NONBLOCK
    • prevent the OS from assigning the opened file as the process's controlling terminal when opening a TTY device file. O_NOCTTY

mode If contains , will set the permissions of the file (creation permissions). is required for correct operation when is specified in and is ignored otherwise. flags``O_CREAT``mode``mode``O_CREAT``flags

   The actual permissions assigned to the created file will be
   affected by the process's  setting as
   per usual.
  *umask*

A file descriptor or false on error.

Voorbeeld: Opening a file descriptor

<?php

$fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK);

dio_close($fd);
?>

dio_close