我正在尝试做的事情非常明显。我正在尝试将txt文件写入当前页面。不幸的是,txt文件是空白的。
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
<?php
$var_str = var_export($pageURL, true);
$var = "<?php\n\n\$$pageURL = $var_str;\n\n?>";
file_put_contents('kylie.txt', $var);
?>
答案 0 :(得分:0)
你没有调用函数来获取url:
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$pageURL = curPageURL(); // Added this line to pick up the current url
$var_str = var_export($pageURL, true);
$var = "<?php\n\n\$$pageURL = $var_str;\n\n?>";
file_put_contents('kylie.txt', $var);
?>