Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP switch case Connects
    primarykey
    data
    text
    <p>I have the following code:</p> <pre><code>switch ($page) { default: $page = 'error'; // header require_once 'pages/header.php'; // content require_once 'pages/error.php'; break; case 'index': case 'login': case 'register': case 'profile': // header require_once 'pages/header.php'; // content if (file_exists('pages/' . $page . '.php')) require_once 'pages/' . $page . '.php'; break; } /* * Footer */ require_once 'pages/footer.php'; </code></pre> <p>Now let's take an example, and apply the following code to header.php:</p> <pre><code>if ($page == 'profile'): include 'members/core/init.php'; if(isset($_GET['username']) &amp;&amp; empty($_GET['username']) === false) { $username = htmlentities($_GET['username']); if ($users-&gt;user_exists($username) === false) { header('Location:index.php'); die(); }else{ $profile_data = array(); $user_id = $users-&gt;fetch_info('id', 'username', $username); $profile_data = $users-&gt;userdata($user_id); } endif; </code></pre> <p>And the following, to footer.php:</p> <pre><code>if ($page == 'profile'): }else{ header('Location: index.php'); } endif; </code></pre> <p>Site structure it's following:</p> <p><strong>index.php</strong></p> <p><strong>pages</strong> (Folder)</p> <p>=</p> <p>header.php</p> <p>index.php</p> <p>footer.php</p> <p>profile.php</p> <p>But the problem its header.php and footer.php , wich seems to not make connection one with another, cuz i receive the following error:</p> <p><strong>Parse syntax error, T_ENDIF</strong></p> <p>How can i change code to make connection for header.php with footer.php ?</p> <p>Cheers!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload