PHP终结篇:继续冒险历程

来源:互联网 发布:w3m linux 编辑:程序博客网 时间:2024/05/29 00:34
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

 

如果你喜欢冒险,并且在Windows上运行CGI、ISAPI或Apache模块版本的PHP,那么你就可以访问COM的函数。好了,详细解释COM的工作就交给微软和许多大部头的书了,为了能简单地了解一下COM的功能,下面是一小段常见的脚本。

  这段PHP脚本将在系统后端启动微软的字处理软件Word,并打开一个新的文档,然后输入一些文字,最后保存文档并关闭Word。具体程序如下:

  <?

  // 建立一个指向新COM组件的索引

   = new COM("word.application") or die("Can't start Word!");

  // 显示目前正在使用的Word的版本号

  echo "Loading Word, v. {->Version}<br>";

  // 把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)

  // to open the application in the forefront, use 1 (true)

  ->Visible = 0;

  // 在Word中创建新的文档

  ->Documents->Add();

  // 在新文档中添加文字

  ->Selection->TypeText("Testing 1-2-3...");

  //把文档保存在Windows临时目录中

  ->Documents[1]->SaveAs("/Windows/temp/comtest.doc");

  // 关闭与COM组件之间的连接

  ->Quit();

  // 在屏幕上显示其他信息

  echo "Check for the file...";

  ?>

  如果你有一个Intranet网站,数据存储在SQL Server中,而用户需要这些数据的Excel格式,我们就可以让PHP运行必要的SQL查询并对输出进行格式化,然后利用COM打开Excel,把数据转化为Excel格式的数据,最后把数据保存在用户的台式机上。

  PHP的专题讲座到此就告一段落了,希望通过这次系列讲座,能让大家对PHP有一个初步的了解与认识,其实,我们所介绍的也只是PHP技术的皮毛而已,我们的冒险才刚刚开始,但是只要我们能充满热情和兴趣,相信不久的将来,大家一定会精通掌握PHP应用开发技术的。


<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击