-2
<?php
function put()
    {
$result = mysql_query("SELECT * FROM members WHERE Website_Name = '$GLOBALS[str]'") or die(mysql_error());
?>
<div id='container' style='width:100%'>
<style>
h1 {font-size:45px;}
</style>
<div id='header' style='background-color:#FFFFFF;'>
<h1 style='margin-bottom:0;margin-top:0;height:20%;float:center;'>
<?php
while($row = mysql_fetch_array($result))
{?>
<table align='left'><tr><td><img src="$row[Website_Name]/index.jpg" align='center' width='240' height='170'></td></tr></table>
<table align='center'><br><tr><td><h1>"$row[Business_Name]"</td></tr></table>
<?php
}
 ?>

file_put_contents("'$GLOBALS[str]'/index.php",put());

我正在使用 file_put_contents() 方法..但它没有将数据写入文件。

4

2 回答 2

1

因为你的函数put没有return任何数据。它将文本写入输出,但它什么也不做return。因此没有任何内容写入文件。在此处了解函数返回值:http ://www.php.net/manual/en/functions.returning-values.php

此外,我认为"'$GLOBALS[str]'/index.php"这不是一个有效的文件名。

于 2013-02-18T06:41:31.340 回答
0

$data = "你的数据";

$file = uniqid().'.php'; //如果你不想创建文件,你可以使用你现有的文件。

$success = file_put_contents($file, $data);

于 2013-02-18T07:07:42.120 回答