fwrite

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     public function write($contents)

    {

        fwrite($this->handle, $contents);



        fflush($this->handle);
<?php             default => $output,

        };



        fwrite($this->outputStream, $output);



        $this->dumping = false;

    }
<?php                 return;

            }



            fwrite($sink, $body);

            rewind($sink);

        };

    }
<?php     {

        $tmpfile = tmpfile();



        fwrite($tmpfile, $content);



        return tap(new File($name, $tmpfile), function ($file) use ($tmpfile) {

            $file->sizeToReport = fstat($tmpfile)['size'];
<?php             call_user_func($functionName, $image);



            fwrite($temp, ob_get_clean());

        });

    }

}
<?php         $this->assertFalse($disk->prepend('path.txt', 'data'));

        $this->assertFalse($disk->append('path.txt', 'data'));

        $handle = fopen('php://memory', 'rw');

        fwrite($handle, 'content');

        $this->assertFalse($disk->writeStream('path.txt', $handle));

        fclose($handle);
<?php     {

        $string = 'Look at me, i am a stream!!';

        $resource = fopen('php://temp', 'w');

        fwrite($resource, $string);

        rewind($resource);

        $body = Utils::streamFor($resource);
<?php         $response = TestResponse::fromBaseResponse(

            new StreamedResponse(function () {

                $stream = fopen('php://memory', 'r+');

                fwrite($stream, 'expected response data');

                rewind($stream);

                fpassthru($stream);

            })
<?php         $exitCode = $application->runTest(realpath(trim($testPath)));



        fwrite($statusFile, (string) $exitCode);

        fflush($statusFile);

    }

})();
<?php             $teamcityProgress = $this->tailMultiple($teamcityFiles);



            if ($this->teamcityLogFileHandle !== null) {

                fwrite($this->teamcityLogFileHandle, $teamcityProgress);

            }

        }
<?php             $teamcityProgress = $this->tailMultiple($teamcityFiles);



            if ($this->teamcityLogFileHandle !== null) {

                fwrite($this->teamcityLogFileHandle, $teamcityProgress);

                $resource = $this->teamcityLogFileHandle;

                $this->teamcityLogFileHandle = null;

                fclose($resource);
<?php     private function writeStringToStream(string $string, $target): void

    {

        if (@fwrite($target, $string) === false) {

            throw CannotWriteToTemporaryFile::new(error_get_last());

        }

    }
<?php         if (is_string($value)) {

            $fp = fopen('php://temp', 'rb+');

            assert(is_resource($fp));

            fwrite($fp, $value);

            fseek($fp, 0);

            $value = $fp;

        }
<?php         if (is_string($value)) {

            $fp = fopen('php://temp', 'rb+');

            assert(is_resource($fp));

            fwrite($fp, $value);

            fseek($fp, 0);

            $value = $fp;

        }
<?php $basePath = $_SERVER['APP_BASE_PATH'] ?? $_ENV['APP_BASE_PATH'] ?? $serverState['octaneConfig']['base_path'] ?? null;



if (! is_string($basePath)) {

    fwrite(STDERR, 'Cannot find application base path.'.PHP_EOL);



    exit(11);

}