B
B
Bearax2018-08-06 14:39:20
PHP
Bearax, 2018-08-06 14:39:20

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>';
}


?>

But such an error is displayed on the site, or rather, this is not an error, but part of the PHP code.
Zb3GsRTW6v4.jpg

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Eugene Volf, 2018-08-06
@Wolfnsex

To write multiline text, you need to use the construction <<< , then there will be no such errors (pieces of code).

N
Nikita, 2018-08-06
@Rema1ns

Enable Short Open Tag

F
Flying, 2018-08-06
@Flying

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

F
frees2, 2018-08-06
@frees2

<?phpphp put classic error

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question