Re: Making it a function?



On Tue, 5 May 2009 12:05:56 +0200, "Samuel van Laere"
<webkluns@xxxxxxxxxxxx> wrote:

Hi,

I use the code below on my website, straight in the index page (not as a
function that is) and it works just fine.
But when I make it a function:
function LaadPagina()
{
// the code
}

put it in a seperate script, include it and next call the function:
LaadPagina();

It won't work, no page gets loaded, no PHP errors either.

Why won't it work when made in a function?

Cheers,
Samuel -code below -

<?php
$toegestaan = array("index", "doel", "gastenboek", "sponsors", "links",
"doel", "dagboek", "giften", "parcours", "contact", "fotoalbum");
$bestand = './pgn/' . $_GET['id'] . '.php';
if (in_array($_GET['id'], $toegestaan)) {
if (file_exists($bestand)) {
include($bestand);
} else {
$titel = '404 - Bestand niet gevonden.';
$kop = 'Ojee een 404 :(';
$inhoud = '<p>404 - Bestand niet gevonden.</p>';
}
} elseif (!isset($_GET['id'])) {
if (file_exists('./pgn/index.php')) {
include('./pgn/index.php');
}
} else {
header("HTTP/1.0 404 Not Found");
$titel = '404 - Bestand niet gevonden.';
$kop = 'Ojee een 404 :(';
$inhoud = '<p>404 - Bestand niet gevonden.</p>';
}
return $titel;
return $kop;
return $inhoud;
?>

But


Perhaps because it never gets interpreted, only loaded. Not sure
there is a way to put php in a loadable script. Someone more expert
than I might want to comment.
--
Jay (remove dashes for legal email address)
.



Relevant Pages

  • Re: Web Animation and Sound Advice Sought
    ... upon someone landing on my website, ... My blog program is a php program that makes use of a mysql database. ... linux (and the linux server supports all sorts of php). ... $500+ Premiere software -- at least on my first brief experimenting ...
    (misc.writing)
  • Re: Furthering my education in OOP - where/how can one learn professional skills?
    ... but I am not proud of the rather amateurish ... implement them in a website. ... is PHP the best language to use to learn and implement the full ... power of OOP? ...
    (comp.lang.php)
  • Re: Where to define functions as global?
    ... I'm building a website with PHP and MySQL. ... This is a scripting language, ...
    (alt.php)
  • Re: Restricting access to a website
    ... If, for example, my website is www .lahdedah. ... Yes or no would do and a PHP ... It can all be done in the Apache ... work on a shared server for a number of reasons - like he doesn't have access to the firewall configuration and the firewall is web host blind - it doesn't know that the request should be restricted only for one of the sites on the server, ...
    (comp.lang.php)
  • Re: Where to define functions as global?
    ... I'm building a website with PHP and MySQL. ... PHP is a completely different language, and has very little in common with Cobol. ...
    (alt.php)