takn25 Posted January 27, 2011 Share Posted January 27, 2011 Hi again, okay going to be a bit difficult to explain clearly but i will try. For instance i have a script on my categories.php ready to run when called from index.php I land on this page no 1 /categories.php?name=$pagename from there the user has an option to go this page 2, /categories.php?name=$pagename&id=$myid <--- ok my question.. is it best to carry on scripting on categories.php for both pages (urls) or is it best to make another page example categories2.php for page number 2. Currently all my code is on categories.php and it is performing as desired. Still i want to know which is better and how do you guys work, if you have a similar case any suggestions and guidance would be appreciated thanks all. Link to comment https://forums.phpfreaks.com/topic/225818-another-question-about-urls-and-how-to-work-with-them/ Share on other sites More sharing options...
nderevj Posted January 27, 2011 Share Posted January 27, 2011 My gut tells me that you should create another PHP file to process the 2nd page / step. This feeling comes from the idea of script responsibility. Similar to if you give a class, method or even a standalone function too much responsibility it becomes difficult to maintain. The same might be said for reusing the categories.php script. I also envision an efficiency issues with reusing categories.php- the logic you have when the user lands at page 1, will be re-executed for page 2. Re-executing this logic might be meaningless and a waste of resources. Lastly if you need to make a change to page 1's logic (say you discover a bug or need to add a new feature) you're most likely going to break page 2 if you re-use categories.php. If your concern is propagating the $pagename variable to the various pages Id suggest using sessions or appending the parameter onto the URL for the next page. - Nick Link to comment https://forums.phpfreaks.com/topic/225818-another-question-about-urls-and-how-to-work-with-them/#findComment-1165871 Share on other sites More sharing options...
takn25 Posted January 27, 2011 Author Share Posted January 27, 2011 Thanks for the wonderful reply! Link to comment https://forums.phpfreaks.com/topic/225818-another-question-about-urls-and-how-to-work-with-them/#findComment-1165902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.