我有我的代码行
textinjector("/var/www/html/uploadTest/test2.php", 26, "'test' => array('$this', 'getTestData'),");
我需要将$ this变量打印为: “$这个”
而不是存储在$ this中的值。
我的完整代码:
$PageTitle = "shop";
$PageTitleCaps = ucfirst($PageTitle);
echo "Caps is $PageTitleCaps";
// this function injects the injTesxt into the line number in the document directory
function textinjector($file, $linerNumber, $injText ) {
$content = file($file); //Read the file into an array. Line number => line content
foreach($content as $lineNumber => &$lineContent) { //Loop through the array (the "lines")
if($lineNumber == $linerNumber) { //Remember we start at line 0.
$lineContent .= $injText . PHP_EOL; //Modify the line. (We're adding another line by using PHP_EOL)
}
}
$allContent = implode("", $content); //Put the array back into one string
file_put_contents($file, $allContent); //Overwrite the file with the new content
echo "$injText was injected to $file at line number $lineNumber";
}
textinjector("$fileDirectory", 26, '"test" => array("$this", "getTestData"),');
任何sugestions?
答案 0 :(得分:0)
好的,找到了我自己的方法。
刚刚创建了一个单独的变量,即$ thisVar
然后添加
$thisVar ='$this';
echo $thisVar;
现在将回显
$this
耶。 谢谢所有那些帮助者。
AT