For some reason I’m having trouble accessing the fopen() function from inside a class in PHP:
<?php
class Compare
{
function __construct( ){ }
private $q_scores = array();
private $q_path = "./data/questions.txt";
private $questions = fopen($q_path, 'r');
//...
}
?>
How do I access the built-in php functions from inside the class?
Many thanks
Put this line in the constructor (it’s made for this)
And simply declare it like: