file_get_contents远程网页总是出现问题

koudaidai 2012-07-19 05:36:50
使用的是smarty
index.php
<?php
//载入Smarty库,如果在php.ini设置了include_path为D:\smarty\libs,那么可以直接用include("Smarty.class.php");
//另外不设置include_path,可以直接把Smarty.class.php拷到网站目录,就不用加绝对路径了。
require('D:\smarty\libs\Smarty.class.php');
// require('Smarty.clas.php');
define('_ROOT_SITE','C:\webSite\url');
$smarty=new Smarty;
//下面的(你的网站目录)用绝对路径,可以用相对路径(./templates)
$smarty->template_dir="C:\webSite\url\templates";
$smarty->config_dir="C:\webSite\url\configs";
$smarty->cache_dir="C:\webSite\url\cache";
$smarty->compile_dir="C:\webSite\url\templates_c";
//上面四行为使用Smarty前的必要参数配置
$smarty->left_delimiter='<{';
$smarty->right_delimiter='}>';
?>
test.php
<?php
require "C:\webSite\url\index.php";
$url_1="http://www.yahoo.com";
$smarty->assign('url_1',$url_1);
$html_1 = file_get_contents($url_1,'r');
$smarty->assign('html_1',$html_1);
$smarty->display('C:\webSite\url\templates\test.htm');
?>
test.htm
<html>
<head>
<title>显示网址</title>
</head>
<body>
<pre>
<{$url_1}>
<hr>
<{$html_1}>
</pre>
</body>
</html>
出现问题
atal error: Uncaught exception 'SmartyException' with message 'unable to write file C:\webSite\url emplates_c\wrt5007d32beb7679.82967547' in D:\smarty\libs\sysplugins\smarty_internal_write_file.php:44 Stack trace: #0 D:\smarty\libs\sysplugins\smarty_internal_template.php(201): Smarty_Internal_Write_File::writeFile('C:\webSite\url?...', '<?php /* Smarty...', Object(Smarty)) #1 D:\smarty\libs\sysplugins\smarty_internal_templatebase.php(155): Smarty_Internal_Template->compileTemplateSource() #2 D:\smarty\libs\sysplugins\smarty_internal_templatebase.php(374): Smarty_Internal_TemplateBase->fetch('C:\webSite\url\...', NULL, NULL, NULL, true) #3 C:\webSite\url\test.php(7): Smarty_Internal_TemplateBase->display('C:\webSite\url\...') #4 {main} thrown in D:\smarty\libs\sysplugins\smarty_internal_write_file.php on line 44
...全文
4494 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧