写入file_put_contents()
调用file_get_contents();

解决方案 »

  1.   

    程序员,还想没日没夜的干下去吗??最新项目:懂网络,零投入,不耽误正常工作,业余时间让你月赚2000!!!!!! 
    财富网址:www.dmdigo.cn
      

  2.   

    少量的信息可以存储到cookie里
      

  3.   


    $str = '<?php
    $arr1 = array(
      "text"=>"Fair",
      "code"=>"34",
      "temp"=>"7",
      "date"=>"Thu, 10 Apr 2008 9:50 am BST"
      );
    ?>';你就把数组直接写到test.php里面,要用的时候一个include就得到了数组的值,输出不就可以了。
    要写到txt里面的话,写成个字符串自己定义个符号分割,回头read了再拆分就可以了。
      

  4.   

    按照你的恩路,我给你更细一点的分一下.
    一:你要把数据写进文本文件,这个数据从哪来?数据库还是文本文件,或者说从页面中所提交的信息来?
    二:数据保存在一个数组中(目的是为之后写入文本文件准备)
    三:文本文件在目录中是存在还是不存在.如果要写入的文本文件不存在,是否新建一个文本文件
    四:如果文本文件存在,那么这个文件是个空文件还是有数据的文件
    五:如果有数据,是追加在已有数据之后还是删除掉原来的重新写入数据
    提示:所有数据均围绕数组来进行.
    你可以按以上步骤进行思考,之后便可有解.
    参考:http://blog.csdn.net/zmouki/archive/2008/04/15/2292696.aspx
      

  5.   

    以上参考中有shop.php文件,你在<图片修改功能>的最后部分会看到一个循环,这个循环就是在写入数据,之前的部分都是在为数组中的数据做准备.你可以参考一下.其间有用的函数 fwrite,fopen, mkdir,is_dir,参考手册了解其用法.
      

  6.   

    不是用fopen,那些操作文件的函数就可以了吗?
    查一下手册就知道了.
      

  7.   


    $a = array (1, 2, array ("a", "b", "c"));则,写入文件
    $s = var_export ($a, true);
    file_put_contents('test.php', "<?php \$a = $s; ?>");调用文件
    include 'test.php';print_r($a); //检查结果
      

  8.   


    ///写入文件
    $resouce = fopen('test.txt','a+');
    $test_array = array('dada','dada20042030');
    $test_array_2 = array('dodo','dodo20042030');
    fwrite($resouce,json_encode($test_array));
    fwrite($resouce,json_encode($test_array_2));
    fclose($resouce);//读取文件
    $resouce = fopen('test.txt', 'r+');
    $len = filesize('test.txt');
    $new_str ="";
    for ($i=1; $i<=$len; $i++)
    {
    $data = fread($resouce,1);
    if(($data !='[') && ($data !='"') && ($data !="]"))
    {
    $new_str .= $data;
    }
    if ($data == ']' && $i!=$len)
    {
    $new_str .="|";
    }
    }print_r(explode("|",$new_str));
      

  9.   


    上面一个数组为$f,一个为$cdtn我是初学者, 我先按照上面说的写入test.php
    $s = var_export ($f, true); 
    file_put_contents('test.php', " <?php \$f = $s; ?>"); 
    然后在另一php页面include 'test.php'; 
    print_r($f[0]["low"]); 
    没有显示啊?
      

  10.   

    不可能!
    <?php
    $f = array(
      array(
        "day" => "Thu",
        "date" => "10 Apr 2008",
        "low" => "1",
        "high" => "11",
        "text" => "Light Rain",
        "code" => "11",
      ),
      array(
        "day" => "Fri",
        "date" => "11 Apr 2008",
        "low" => "1",
        "high" => "10",
        "text" => "Light Rain",
        "code" => "11",
      )
    );
    $s = var_export ($f, true); 
    file_put_contents('test.php', " <?php \$f = $s; ?>"); 得到test.php文件 <?php $f = array (
      0 => 
      array (
        'day' => 'Thu',
        'date' => '10 Apr 2008',
        'low' => '1',
        'high' => '11',
        'text' => 'Light Rain',
        'code' => '11',
      ),
      1 => 
      array (
        'day' => 'Fri',
        'date' => '11 Apr 2008',
        'low' => '1',
        'high' => '10',
        'text' => 'Light Rain',
        'code' => '11',
      ),
    ); ?>
    执行<?php
    include 'test.php'; 
    print_r($f[0]['low']); 
    ?>得到 1
      

  11.   


    变量转字符
    学习了
    $s = var_export ($f, true); 不知道带true和不带true有何区别?
      

  12.   

    果然可以如果追加写文件应该怎么办我这样写,不行
    $s = var_export ($f, true); 
    file_put_contents('test.php', " <?php \$f = $s;"); 
    $a = var_export ($cdtn, true); 
    file_put_contents('test.php', "\$cdtn = $a",FILE_APPEND); 
    $b = var_export ($atmp, true); 
    file_put_contents('test.php', "\$atmp = $b;?>",FILE_APPEND); 
    不知道哪里错了?
      

  13.   

    file_put_contents('test.php', " <?php \$f = $s;"); 
      

  14.   

    file_put_contents('test.php', " <?php \$f = $s;"); 
      

  15.   

    file_put_contents() 
    rwrite 进去~~
      

  16.   

    找了半天,也没发现  file_put_contents() 有rwrite功能啊