Problem accessing text file in a class in PHP -
i have 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 prev. question: accessing fopen class in php
the problem $line
never prints , don't know why.
i use class using:
$compare = new compare(); $compare->checkstringforproximity("string");
any appreciated.
in line
while ($line = fgets($questions))
$questions
not exist. should replaced $this->questions
Comments
Post a Comment