实例首页
自学教程
IT工具箱
源代码
点击运行 >
PHP 面向对象 实例 - 自学教程(runoops.com)
url = $par; } function getUrl(){ echo $this->url . PHP_EOL; } function setTitle($par){ $this->title = $par; } function getTitle(){ echo $this->title . PHP_EOL; } } $runoops = new Site; $taobao = new Site; $google = new Site; // 调用成员函数,设置标题和URL $runoops->setTitle( "Runoops教程" ); $taobao->setTitle( "淘宝" ); $google->setTitle( "Google 搜索" ); $runoops->setUrl( 'www.runoops.com' ); $taobao->setUrl( 'www.taobao.com' ); $google->setUrl( 'www.google.com' ); // 调用成员函数,获取标题和URL $runoops->getTitle(); $taobao->getTitle(); $google->getTitle(); $runoops->getUrl(); $taobao->getUrl(); $google->getUrl(); ?>
运行结果: