类的错误

xihuluyou 2006-04-19 02:25:42
类代码:
class Gethttppage
{
var $value_ ; //'目标内容

function __set($name,$value)
{
$this->name=$value;
}

function __get($name)
{
return $this->name;
}

function __construct($url)
{
$this->value_=file_get_contents($url); //(PHP 4 >= 4.3.0, PHP 5)
}

function cut($start,$end,$no='1',$comprise='')
/*
按指定首尾字符串对收集的内容进行裁减的的方法
$no 必须是 1,2 3 ... 不允许 0
$comprise 可以选择 start 或者 end 或者 all 或者 什么都不填
*/
{
$string=explode($start,$this->value_);
//print_r($string);
$string=explode($end,$string[$no]);
//print_r($string);
switch ($comprise){
case 'start':
$string=$start.$string[0];
break;
case 'end':
$string=$string[0].$end;
break;
case 'all':
$string=$start.$string[0].$end;
break;
default:
$string=$string[0];
}
return $this->value_=$string;

}

引用类以后:
$url='http://destinations.ctrip.com/Destinations/Sight.asp?Resource=2022';
$a=new Gethttppage($url);
$a->cut('提供照片','门票')
$cc=$a->value_;
echo $cc;

在$cc=$a->value_; 这句的时候就报错了,请问是为什么呀?
我该怎么取得经过function cut处理以后的值呀?
...全文
88 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xihuluyou 2006-04-19
  • 打赏
  • 举报
回复
哎呀~!!
真是没话说~!!就这么一个分号,我昨天试到晚上3点:(
哭死
以前写asp的,对这个结束就是没概念一样
太谢谢啦~~
Cain 2006-04-19
  • 打赏
  • 举报
回复
引用类以后:
$url='http://destinations.ctrip.com/Destinations/Sight.asp?Resource=2022';
$a=new Gethttppage($url);
$a->cut('提供照片','门票') //这里漏了分号
$cc=$a->value_;
echo $cc;

为什么不这样写?
echo $cc = $a->cut('提供照片','门票');

21,887

社区成员

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

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