Update string.php

This commit is contained in:
myvesta 2020-08-30 05:06:45 +02:00 committed by GitHub
parent 98cc47e654
commit ea0fa49d0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,11 +1,11 @@
<?php
function myvesta_replace_in_file($file, $find, $replace) {
if (!file_exists($file)) return myvesta_throw_error (3, "File '$file' not found");
if (!file_exists($file)) return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "File '$file' not found");
$buf=file_get_contents($file);
if (strpos($buf, $find)===false) return myvesta_throw_error (4, "String '$find' not found");
if (strpos($buf, $find)===false) return myvesta_throw_error (MYVESTA_ERROR_STRING_DOES_NOT_EXISTS, "String '$find' not found");
$buf=str_replace($find, $replace, $buf);
$r=file_put_contents($file, $buf);