So I've been using a procedural programming style in PHP since 2006. But missed out on a lot of time the past 4+ years with getting any better.
Recently I've started to acknowledge object oriented programming more.
The thing that points out to me with it the most, is the MVC style organization and short urls.
instead of url being "index.php?page=profile&member=1", it would be "page/profile/member/1".
I'm trying to learn OOP&MVC architecture with using a wide range of resources, but it is still a bit too much for me to grasp. Even after a month!
I've always just used basic function(etc) {}, if,else,and,or statements and SQL queries to get the job done. That knowledge up til now has mostly covered everything I needed.
I'm wondering if there is a way to use my basic procedural programming style and still achieve shortened urls?
I've tried this method below
.htaccess
RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?page=$1 [L]
index.php
<?php
$links = parse_ini_file('links.ini');
if (isset($_GET['page']) && array_key_exists($_GET['page'], $links)) {
require $links[$_GET['page']];
}
else {
echo '
Home page or unknown link
';
}
links.ini
members = pages/members.php
profile = pages/profile.php
This method works on simply shortening a URL, but I don't know how to make it work with profile/user/1 aka index.php?page=profile&user=1 (the user variable being a database query)
Any help would be greatly appreciated!!!