I want to use mod_rewrite with PHP, parse the URL with this format:
http://www.domain.com/Path-to-index.php/Class_to_Load/Function_to_Execute/Arguments_as_array_to_the_function
The class to load will be included of the directory classes, with a strtolower then ucfirst, like:
http://www.domain.com/Path-to-index.php/SAMPLE will include classes/Sample.php and execute the function action_index, because no function was used.
Then, when this url is open: http://www.domain.com/Path-to-index.php/SAMPLE/Login/User, PHP should include classes/Sample.php and execute action_Login($args = Array(0 => "User"));.
Please I need to know how to do that.
Your index.php could look something like this:
Your .htaccess for removing index.php from the url:
It’s always interesting to roll your own framework to learn more about PHP, but if you are really coding something bigger, I highly recommend using a well-known and well-documented framework. There are a lot of good frameworks out there, which are well-tested and used in production before. Just take a look at all the
@todonotices above. These are all issues, which are already handled by a framework and you don’t need to care about these things.