query regerding copying files using php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello friends,
 
i have a query in writng  the content of one file to another.
i attempted it.
it only writes the html codings.it could not write the php scripts inside the file.
 
i use the following code to accomplish my problem...
 
##############################################################
 
if (!defined('T_ML_COMMENT')) {
   define('T_ML_COMMENT', T_COMMENT);
} else {
   define('T_DOC_COMMENT', T_ML_COMMENT);
}
$source = file_get_contents('-.php');
$tokens = token_get_all($source);
foreach ($tokens as $token) {
   if (is_string($token)) {
       // simple 1-character token
       $ourFileName = "/home/itempla1/public_html/links/".$pwd.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
      echo $token;
       fwrite($ourFileHandle, $token);
fclose($ourFileHandle);
   } else {
       // token array
       list($id, $text) = $token;
       switch ($id) {
           case T_COMMENT:
           case T_ML_COMMENT: // we've defined this
           case T_DOC_COMMENT: // and this
               // no action on comments
               break;
           default:
               // anything else -> output "as is"
               $ourFileName = "/home/itempla1/public_html/links/".$pwd.".php";
$ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");
               echo $text;
               fwrite($ourFileHandle, $text);
fclose($ourFileHandle);
               break;
       }
   }
}

?>
################################################################
 
 
 
please give me some valuable tips to write the content of the php file to another newly created php file.
 
 
Thanks,
 
Suresh.P

		
---------------------------------
 Yahoo! India Matrimony: Find your partner now.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux