Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Binary-safe file write
Alias fputs
<?php fwrite(resource $stream, string $data, ?int $length = null): int|false
<?php }



if (DIRECTORY_SEPARATOR === '\\') {

    fwrite(STDERR, 'Non-blocking console I/O not supported on Microsoft Windows' . PHP_EOL);

    exit(1);

}
<?php }



if (!isset($argv[1])) {

    fwrite(STDERR, 'Usage error: required argument <host:port>' . PHP_EOL);

    exit(1);

}
<?php $parts = parse_url($uri);



if (!$parts || !isset($parts['scheme'], $parts['host'])) {

    fwrite(STDERR, 'Usage error: required argument <host:port>' . PHP_EOL);

    exit(1);

}
<?php                         @\fwrite($stream, \PHP_EOL);

                        $error = \error_get_last();
<?php             $request = stream_socket_recvfrom($socket, 65536, 0, $peer);



            $client = stream_socket_client('udp://8.8.8.8:53');

            fwrite($client, $request);

            $response = fread($client, 65536);



            stream_socket_sendto($socket, $response, 0, $peer);
<?php     {

        $client = stream_socket_client('tcp://localhost:'.$this->port);



        fwrite($client, "foo\n");



        $mock = $this->expectCallableOnceWith("foo\n");
<?php     public function testDataWillBeEmittedEvenWhenClientShutsDownAfterSending()

    {

        $client = stream_socket_client('tcp://localhost:' . $this->port);

        fwrite($client, "foo\n");

        stream_socket_shutdown($client, STREAM_SHUT_WR);



        $mock = $this->expectCallableOnceWith("foo\n");
<?php     {

        $client = stream_socket_client($this->uds);



        fwrite($client, "foo\n");



        $mock = $this->expectCallableOnceWith("foo\n");
<?php     public function testDataWillBeEmittedEvenWhenClientShutsDownAfterSending()

    {

        $client = stream_socket_client($this->uds);

        fwrite($client, "foo\n");

        stream_socket_shutdown($client, STREAM_SHUT_WR);



        $mock = $this->expectCallableOnceWith("foo\n");