Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<COMPersistHelper::LoadFromStreamCOMPersistHelper::SaveToStream>
^COMPersistHelperLast updated: Mon, 26 Oct 2026

COMPersistHelper::SaveToFile

(PHP 5, PHP 7, PHP 8)

COMPersistHelper::SaveToFile — Save object to file

Description

public function COMPersistHelper::SaveToFile(?string $filename, bool $remember = true): bool

Saves a copy of the object to the specified file.

Parameters

filename

The name of the file to which to save the object.

remember

Indicates whether the filename parameter is to be used as the current working file. If true, filename becomes the current file and the object is supposed to clear its dirty flag after the save. If false, this save operation is a "Save A Copy As ..." operation. In this case, the current file is unchanged and the object is not supposed to clear its dirty flag.

Return Values

Returns true on success or false on failure.

Errors/Exceptions

A com_exception is thrown if the associated object does not implement the COM interface IPersistFile, or when calling the IPersistFile::Save() method failed.

Examples

Example #1 Basic COMPersistHelper::saveToFile() Usage

<?php
$word = new COM('Word.Application');
$doc = $word->Documents->Add();
$ph = new COMPersistHelper($doc);
$ph->SaveToFile('C:\\Users\\cmb\\Documents\\my.docx');
$word->Quit();
?>

<COMPersistHelper::LoadFromStreamCOMPersistHelper::SaveToStream>
^COMPersistHelperLast updated: Mon, 26 Oct 2026