一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

php入门教程一(对文件访问实现)

时间:2010-11-04 编辑:简简单单 来源:一聚教程网

对文件访问实现的源代码。主要讲到php教程操作文件以及xml文档实例方法。

// 创建一个新的pdf文档句柄
$pdf = cpdf_open(0);
// 打开一个文件
cpdf_open_file($pdf);
// 开始一个新页面(a4)
cpdf_begin_page($pdf, 595, 842);
// 得到并使用字体对象
$arial = cpdf_findfont($pdf, "arial", "host", 1);
cpdf_setfont($pdf, $arial, 10);
// 输出文字
cpdf_show_xy($pdf, "this is an exam of pdf documents, it is a good lib,",50, 750);
cpdf_show_xy($pdf, "if you like,please try yourself!", 50, 730);
// 结束一页
cpdf_end_page($pdf);
// 关闭并保存文件
cpdf_close($pdf);

// 如果要直接输出到客户端的话,把下面的代码加上

$buf = cpdf_get_buffer($pdf);

$len = strlen($buf);

header("content-type: application/pdf");

header("content-length: $len");

header("content-disposition: inline; filename=pie_php.pdf");

print $buf;

cpdf_delete($pdf);
?>

xml文件

$dom = new domdocument();
$dom->load("order.xsl");
$proc = new xsltprocessor;
$xsl = $proc->importstylesheet($dom);

$xml = new domdocument();
$xml->load('order.xml');
$string = $proc->transformtoxml($xml);
echo $string;
?>

order.sls


http://www.w3.org/1999/xsl/transform">

 

 
   
     
       
         
         
       

     
   
 

 
   
   
   


     
       
       
       
       
       
       
     
              
     

   
订单号 id 说明 价格 数量 合计

 
 
   
     
     
     
     
     
     
   
 
    

order.xml文件



  9900234
 
    1234
    5.95
    100
    595.00
    www.111com.net
 

 
    6234
    22.00
    10
    220.00
    足球
 

 
    9982
    2.50
    1000
    2500.00
    手机包
 

 
    3256
    389.00
    1
    389.00
    手机
 

  www.111com.net
  3704.00
  07/07/2002
  8876

 

 

热门栏目