Jump to content

PHP code file structures


okhokhar

Recommended Posts

Hi,

I'm sort of new to PHP and I had a question about how exactly to structure PHP code. I am building a site to assist in a manufacturing process. The website has multiple different aspect like packaging, shipping, view test results etc... Right now I have created multiple files within each group. For example in the packaging section I have 7 different scripts. Within the packaging section I have been using the action field in a form as well as location.href to jump around the multiple scripts in packaging, so depending on what step of a process the user is in the URL link would be different. However I was recently told that my method is incorrect and I should have one page that controls the access to all other scripts in packaging. As an example I would then have a page called packagingContorl.php and within that file I would have a case statement for each step and then I'd still have the multiple files but packagingControl.php would decide which script to call using include statements. As I'm not familiar with the best coding practices in PHP any help would be appreciated.

 

Also on a side note I have been putting try-catch statements in all my database access classes and if an error pops up I send the error message to the catch block which will print the message out. However, I was told that having too many try-catch statements is also inefficient. Is this correct?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.