Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Opens file or URL
fopen(    string $filename,    string $mode,    bool $use_include_path false,    ?resource $context null): resource|false
    {

        
$contents '';



        
$handle fopen($path'rb');



        if (
$handle) {

            try {
    public function putFileAs($path$file$name$options = [])

    {

        
$stream fopen(is_string($file) ? $file $file->getRealPath(), 'r');
    protected function createResource($path$mode)

    {

        
$this->handle = @fopen($path$mode);



        if (! 
$this->handle) {

            throw new 
Exception('Unable to create lockable file: '.$path.'. Please ensure you have permission to create files in this location.');
        file_put_contents($this->tempDir.'/foo.txt''some-data');



        
$filesystemAdapter = new FilesystemAdapter($this->filesystem$this->adapter);

        
$stream fopen($this->tempDir.'/foo.txt''r');

        
$guzzleStream = new Stream($stream);

        
$filesystemAdapter->put('bar.txt'$guzzleStream);

        
fclose($stream);
    {

        
$this->factory->fakeSequence()->push('abc123');



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



        
$this->factory->sink($resource)->get('https://example.com');
            'foo.com/*' => ['page' => 'foo'],

        ]);



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



        
$this->factory->sink($resource)->get('http://foo.com/test');