Answer the question
In order to leave comments, you need to log in
What causes an error in PHP?
Hello, friends. I have such a problem. I wrote the following code in PHP:
<?
if ( $_SERVER['REQUEST_URI'] == '/' ) $page = 'home';
else {
$page = substr($_SERVER['REQUEST_URI'], 1);
if ( !preg_match('/^[A-z0-9]{3,15}$/', $page) ) exit('error url');
}
session_start();
if ( file_exists('all/'.$page.'.php') ) include 'all/'.$page.'.php';
else if ( $_SESSON['ulogin'] == 1 and file_exists('auth/'.$page.'.php') ) include 'auth/'.$page.'.php';
else if ( $_SESSON['ulogin'] != 1 and file_exists('guest/'.$page.'.php') ) include 'guest/'.$page.'.php';
else exit('Страница 404');
function top( $title ) {
echo '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>'.$title.'</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="wrapper">
<div class="menu">
<a href="/">Главная</a>
<a href="/login">Вход</a>
<a href="/register">Регистрация</a>
</div>
<div class="content">
<div class="block">
';
}
function bottom() {
echo '
</div>
</div>
</div>
</body>
</html>';
}
?>
Answer the question
In order to leave comments, you need to log in
To write multiline text, you need to use the construction <<< , then there will be no such errors (pieces of code).
Turned off the short_open_tag setting in php.ini, but in general its use is now considered bad practice, you should use a full-fledged <?php tag
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question