当我尝试str_replace
输入文件名时,fff.php
我无法将$var
名称打印到文件中。
<?PHP
$path_to_file = 'fff.php';
$var_str = var_export($viewer, true);
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace("//","case \"13\";
$viewer =\"jjhj/jhjh/344.mp3\"; //I put value to variable
echo $viewer ; //Here I need to print the $ and name of the variable only
break;
//",$file_contents);
file_put_contents($path_to_file,$file_contents);
echo "your file is ok";
?>
看看当我尝试替换变量的名称而不是值时,看看结果会发生什么 -
fff.php
<?php
$id=$_GET['id'];
switch ($id){
case "1";
$viewer = "jhhghg/pic1.jpg";
echo $viewer ;
break ;
// my str_replace starting
case "13";
="jjhj/jhjh/344.mp3"; //I put value to variable but now name empty
echo ; //Here I need to print the $ and name of the variable only also here
break;
//
//my str_replace end
default;
echo"your request error";
}
?>
那是我的问题,我只需要打印变量名。我怎么做?