i would like to change some variable name in my php file, for example $basePath to $myPath. this is my functions
Code: Select all
function patchFile( $file, $search, $replace ) {
if ( $fp = fopen( $file, 'r' ) ) {
$content = fread( $fp, filesize( $file ) );
fclose($fp);
}
else {
// return error message
}
if( strpos( $content, $value ) === true ) {
//$this->_isPatch = true;
}
// we didn't find it, proceed to patch process
else {
$content = str_replace( $search, $replace, $content );
if( $fp = fopen( $file, 'w' ) ) {
fwrite( $fp, $content, strlen( $content ) );
fclose( $fp );
unset( $content );
echo 'Done!';
} else {
unset( $content );
// return error message
echo 'Error!';
}
}
}
function start() {
$file = "D:/XAMPP/xampp/htdocs/my/tryout/xsecure/administrator/auth.php";
$search = "$basePath";
$replace = "$mypath";
patchFile( $file, $search, $replace );
}Code: Select all
$basePath = dirname( __FILE__ );
require( $basePath . '/sources.php' );
$basePath = dirname( __FILE__ );
require( $basePath . '/config.php' );
/*
other code....
....
....
*/thank you for your help.