在PHP中访问类中的文本文件时出现问题
我有以下代码:在PHP中访问类中的文本文件时出现问题,php,Php,我有以下代码: <?php class Compare { private $questions; private $q_scores = array(); private $q_path = "data/questions.txt"; function __construct( ) { ini_set('auto_detect_line_endings',
<?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;
}
}
}
?>
非常感谢您的帮助。请排队
while ($line = fgets($questions))
$questions
不存在。它应该被替换为$this->questions
谢谢你的帮助。。。当然忘了尝试$this
对象引用。
while ($line = fgets($questions))