本文整理汇总了PHP中Room::result方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::result方法的具体用法?PHP Room::result怎么用?PHP Room::result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::result方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: result
// return $this->doors;
// echo '<pre>';
// print_r($this->doors);
// echo '</pre>';
}
return $this->doors;
}
public function result()
{
return $this->parse(1);
}
}
ob_start();
$room = new Room(50);
echo '<pre>';
print_r($room->result());
echo '</pre>';
$output = ob_get_clean();
$filename = '21.html';
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!($handle = fopen($filename, 'w'))) {
echo "Cannot open file ({$filename})";
exit;
}
//prepare the finish statements
// Write $somecontent to our opened file.
if (fwrite($handle, $output) === FALSE) {
示例2: parse
}
class Room
{
private $doors = array();
function __construct($number)
{
for ($i = 1; $i <= $number; $i++) {
$this->doors[] = new Door();
}
}
public function parse($step)
{
for ($i = $step; $i <= count($this->doors); $i += $step) {
$this->doors[$i - 1]->toggle();
}
if ($step <= count($this->doors)) {
$this->parse($step + 1);
} else {
echo '<pre>';
print_r($this->doors);
echo '</pre>';
}
}
public function result()
{
return $this->parse(1);
}
}
$room = new Room(50);
$room->result();