model view controller - how do I split this php file into MVC format?

i'm learning to program in OOP MVC,
I have this code for a simple nav menu:
<?php
$directory = "views";
$scannedDirectory = glob("$directory/*.php");
function uppercaseSpace($str) {
$re = '/(?=[A-Z][a-z])(?<!^)|(?=[A-Z])(?<=[a-z])/m';
$subst = ' ';
$result = preg_replace($re, $subst, $str);
return $result;
}
?>
<div id="header2">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" href="http://<?php echo $HOST ?>">Home</a>
</li>
<?php foreach ($scannedDirectory as $key => $value) {
$articleName = substr($value,6,-4);
printf('
<li class="nav-item">
<a class="nav-link active" href="?page=%s">%s</a>
</li>
',$articleName, ucfirst(uppercaseSpace($articleName)));
} ?>
</ul>
</nav>
</div> <!-- /header -->
I have a function in the php file so I could make a class navmenu.class and make a method of this function and put the frist 2 lines in the class as a property and the last html part becomes a view right?
but is this class a model or is it a controler?
here is a screenshot of my current file structure:
Is it worth to split this small code into MVC?
This file is now put in the subfolder includes because I am including the nav menu in my script.
Answer
Solution:
Models are for database, View to render html, Controllers to handle a request Beside that you can have helper classes and core classes
Follow some tutorials on how to create a mvc.
https://www.youtube.com/watch?v=OsCTzGASImQ&list=PLfdtiltiRHWGXVHXX09fxXDi-DqInchFD
https://www.youtube.com/watch?v=rkaLJrYnpOM&list=PLFPkAJFH7I0keB1qpWk5qVVUYdNLTEUs3
I followed the one of Curtis Parham he explained everything very well. After completing his tutorial I modified his framework alot by including composer, twig and changed the routing on how to handle variables and multiple languageses.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: err_ossl_pem_no_start_line
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.