I have this code:
<?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;
}
}
}
?>
This relates to my prev. question: Accessing fopen from a class in PHP
The problem is that $line never prints and I don’t know why.
I use this class by using:
$compare = new Compare();
$compare->checkStringForProximity("string");
Any help much appreciated.
In the line
$questionsdoes not exist. It should be replaced with$this->questions