D
D
Denis Adamov2020-04-24 18:00:10
PHP
Denis Adamov, 2020-04-24 18:00:10

Why is the file not included?

Good afternoon, I have a problem with connecting a file with a class.
I made a simple SEF link system:

session_start();
$uri = trim(preg_replace('#(\?.*)?#', '', $_SERVER['REQUEST_URI']), '/');
if (gettype($uri) !== "string") {
    die;
}

switch ($uri) {
    case '':
        include 'templates/main.php';
        break;
}


As you can see, here, depending on the uri, the desired page is connected.
On this page, there is such a code that includes a file with a class and calls the desired method.

include 'lib/Function.php';
$func = new Function;
$one = $func->print();
echo $one;


The class itself contains this code:
class Function
{
    public function print() {
        $one = 1;
        return $one;
    }
}


As a result, the page that should be displayed in the right path does not work for me. (Page not available, error 500).
Please help me to deal with this problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2020-04-24
@ThunderCat

error 500 is a general error, that is, in fact, there can be any error, but since you have suppressed error output, a general error is given - 500. See the logs, or turn on error output to get a real error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question