optimization - The best way to handle content in virtual url - php -


I have an application with PHP in the MVC pattern and smart template engine. And there is no problem with Apache and rewriting engine. And I try to handle the URL and load content in my code with this code: I split the request of $ req array:

  ... ... Load All Libs and Functions Required $ Smarty- & gt; Display ('header.tpl'); // Main switch case switch ($ req [0]) {case 'index.php': './inc/index.php' is required; $ Smarty- & gt; Display ('index.tpl'); break; Case 'list': $ smarty-> Display ('list.tpl'); break; Case 'topic': $ smarty- & gt; Display ('single.tpl'); break; Case 'login': require_once './inc/login.php'; $ Smarty- & gt; Display ('login.tpl'); break; Case 'msg': $ smarty- & gt; Assign ('msg', $ req [1]); $ Smarty- & gt; Display ('message.tpl'); break; Default: $ smarty- & gt; Display ('error.tpl'); break; } $ Smarty- & gt; Display ('footer.tpl');   

Now I think my code is not optimizable and unconventional, and very slow, how can I optimize this code (not always $ req [0] ASCII?)

The best and fastest way [0] requires some patterns in the [0] : $ fname = './inc' '$ rake [0]' .php '; If (file_exists ($ fname)) {insert ($ fname); }

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -