I have written a the beginning of a class and there is already a weird problem:
<?php
include('class-Park.php');
class park_searcher {```
public function __construct() {
// read json file and create each 'Park'
$this->readjson();
}
public function print_parks() {
// print every park as a json array that the javascript can use
}
// read json file and create each 'Park'
public function readjson() {
// read json file and create each 'Park' and add the complete object to an array of every park
// why is readfile() printing the contents of the file?
$raw = readfile("library/parks.txt");
}
}
Instead of readfile()
just setting $raw
to the value of the file, the browser is echoing the contents of the file onto the page. Why is the readfile()
function acting like echo
and printing out the file contents?