无图版
|
左右分栏
» 您尚未
登录
注册
|
搜索
|
朋友圈
|
帮助
社区服务
银行
朋友圈
搜索工具
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训
»
PHP资源共享
»
PHP脚本的8个技巧(6)PHP和COM
交 易
投 票
本页主题:
PHP脚本的8个技巧(6)PHP和COM
打印
|
加为IE收藏
|
收藏主题
|
上一主题
|
下一主题
zhangwei520
级别:
总版主
精华:
0
发帖:
510
威望:
511 点
金钱:
1620 PYMB
贡献值:
10046 点
在线时间:0(小时)
注册时间:2006-12-20
最后登录:2008-01-03
PHP脚本的8个技巧(6)PHP和COM
如果你是一名冒险份子,而且你正在使用CGI、ISAPI或Apache模块版本的Windows系统上运行着PHP,那么你也可以获得系统的COM功能。现在,解释COM(微软的组件对象模型)的工作留给了微软和那些大部头的图书来完成。然而,知道点COM也没什么错,下面有一个普通的(没有双关语,针对很普通)代码小片断。
这代码小片断使用PHP在后台启动Microsoft Word、打开一个新文件、键入一些文本、保存该文件然后关闭应用程序:
<?
// create a reference to a new COM component (Word)
$word = new COM("word.application") or die("Can't start Word!");
// print the version of Word that's now in use
echo "Loading Word, v. {$word->Version}<br>";
// set the visibility of the application to 0 (false)
// to open the application in the forefront, use 1 (true)
$word->Visible = 0;
// create a new document in Word
$word->Documents->Add();
// add text to the new document
$word->Selection->TypeText("Testing 1-2-3...");
//save the document in the Windows temp directory
$word->Documents[1]->SaveAs("/Windows/temp/comtest.doc");
// close the connection to the COM component
$word->Quit();
// print another message to the screen
echo "Check for the file...";
?>
假设你正在运行一个内联网Web站点,该站点把数据存放在Microsoft SQL Server数据库内,你的用户需要Excel格式的数据。那么,你可以让PHP执行必要的SQL查询并且格式化输出结果,然后使用COM启动Excel,把数据传输给它,最后再把文件存储到用户的桌面系统内。
Posted: 2006-12-26 15:08 |
[楼 主]
快速跳至
>> php培训
|- 培训咨询和报名
>> 学员专区
|- 学员交流区
>> 开源项目
|- 项目开发
|- OSC技术交流
|- CMS开源项目研究
|- 下载
>> PHP和web开发
|- 入门和基础知识
|- PHP中高级
|- 网站SEO
|- PHP资源共享
|- YUI,ext JS
|- 数据库应用
|- 操作系统(Windows、Linux)
|- 英语学习
|- 数据结构和算法
|- web2.0
>> 信息发布
|- 招聘和求职
>> 娱乐论坛
|- BT软件&教程发布
|- BT影视&音乐
|- 娱乐乐园
>> PHP世纪
|- 站务管理
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训
»
PHP资源共享
今日推荐
隐藏
显示
关闭
时:01-09 13:39
Copyright © 2006 phpwhy.com 权
ICP05060669
-
系