After checking for both fread and fopen with the search-command "php fread php code" and php fopen php code" without success I'm now turning to asking the question myself. (Over 300 pages with questions were a bit to steep to dig around in.)
I have a page where I get the content from external files. I got the index.php with the links which sends requests through the url (?links=home, for example) that is read from another file that looks through an array and finds the right file. All that works! But here is the tricky part: On of the files includes a few strings of php-codes that won't do it's job but just hangs around in the view-source. Yes, you can see the commands in the source:code, but it won't anything I request. Not a single echo.
Here is some code that might explain things even better.
The code that gets the url-command:
<?php
function load_pages() {
if ($_GET['link'] != NULL) {
$link = $_GET['link'];
$links = array("hem" => "hem.php", "about" => "about.php", "blogg" => "blogg.php", "kontakta" => "kontakta.php");
foreach ($links as $key => $value) {
if ($key == $link) {
$file = "links/" . $value;
$fh = fopen($file, "r") or exit("Unable to open the file.");
$fileContent = fread($fh, filesize($file));
fclose($fh);
echo $fileContent;
}
}
} else {
$file = "links/hem.php";
$fh = fopen($file, "r") or exit("Unable to open the file.");
$fileContent = fread($fh, filesize($file));
fclose($fh);
echo $fileContent;
}
}
?>
The file that gets the command for the page I want to load:
<?php
include ("../include/functions.php");
connect();
?>
<h1>Blogg</h1>
<?php
if ($_GET['id'] == NULL) {
blogg_content();
} else {
blogg_link();
}
?>
<div id="blogg_menu">
<?php blogg_menu(); ?>
</div>
What comes out is: Blogg That just doesn't do the trick, so what might I change to make it give me the blog-content and such? (The page is on Swedish, just to disclaim any typos about "Blogg".)