Documentation

RewriteFile

bool
RewriteFile(
 string abs_path,
 string content
);

The function writes a new content to file. Returns true on success, or false otherwise.

Function parameters

ParameterDescription
abs_path Absolute path to file which is to be overwritten.
content New content of the file.

Notes

If non-existent directories are specified in the absolute path to file, the specified method will create them. For example:

RewriteFile($_SERVER["DOCUMENT_ROOT"]."/en/index.php", $content);

if the /en/ folder does not exist, it will be created.

See Also

Examples of use

<?
// overwrite file /en/index.php
$content = '
    <?
    require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
    $APPLICATION->SetTitle("Page header");
    ?>
    <?
    require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");
    ?>
';
RewriteFile($_SERVER["DOCUMENT_ROOT"]."/en/index.php", $content);
?>


© «Bitrix24», 2001-2024
Up