1
我有这样的代码:问题访问文本文件中的一类PHP
<?php
class Compare
{
private $questions;
private $q_scores = array();
private $q_path = "data/questions.txt";
function __construct()
{
ini_set('auto_detect_line_endings', TRUE);
$this->questions = fopen($this->q_path, 'r');
}
public function checkStringForProximity($string)
{
while ($line = fgets($questions))
{
echo $line;
}
}
}
?>
这涉及到我的分组。问题:Accessing fopen from a class in PHP
问题是$line
从不打印,我不知道为什么。
我通过使用这个类:
$compare = new Compare();
$compare->checkStringForProximity("string");
任何帮助非常赞赏。
谢谢你的......当然忘了试试'$ this'对象引用。 – Alex