I want to edit string of variable. But I can't make it good. The code:
$mysite = 'mysite'; //name of site
$myurl = 'http:/mysite.com'; //url of website
$metaauthor = ''; // meta name author;
$metatitle = 'Online CV Builder'; // meta name title
$metacopy = 'Javid Karimov'; // meta name copyright
$metakeywords = 'CV, PDF, ONLINE, RESUME'; // meta name keywords
$allowcv = '2'; // how many cv's user can create
$keyword = 'cv, pdf, resume, create cv online'; // keyword for creating security key
$mailto = '[email protected]'; // send to mail in contact php
I change like this(IT WORKS):
$str = file_get_contents('../sys/sets.php');
//replace something in the file string
$str = str_replace($mysite, $sitenamexx, $str);
$str = str_replace($myurl, $siteurlxx, $str);
$str = str_replace($metaauthor, $metaavtorxx, $str);
$str = str_replace($metacopy, $metacopyxx, $str);
$str = str_replace($metatitle, $metatitlexx, $str);
$str = str_replace($metakeywords, $metakeywxx, $str);
$str = str_replace($allowcv, $allowcvxx, $str);
$str = str_replace($keyword, $keywxx, $str);
$str = str_replace($mailto, $mailtoxx, $str);
//write string
$wok = file_put_contents('../sys/sets.php', $str);
if($wok) {
echo 'Changed<br/>';
}
else {
echo 'Error<br/>';
}
The question: If the string is empty (for example: $mysite = ''; ) then it does not change. How can I solve it ? May be there is another way ? I tried the way with fopen(), fgets(), and that way I have to use array, but I was not able to use it.
$thingto$thingxx? Or'$thing'to'$thingxx'?