Jump to content

Recommended Posts

Which are considered to be the best programming practices? for example i prefer to not store sessions into files (as done by default by php), but in a database as this gives me the possibility to use the same session on multiple servers, this is possible because of the session_set_save_handler() function! So which do you use (non-oop)?

 

To enlarge the topic a bit: which threads are all out there and how do you solve them (e.g.: cross site scripting)?

Link to comment
https://forums.phpfreaks.com/topic/74070-programming-practices/
Share on other sites

Never let anyone rub there practices off on you.  Listen to multiple view points and do what you think is best.

I PERSONALLY find

MVC a good pattern

OOP a good programming standard.

I also like to avoid ternary operator,  and shorthand all together.

I keep other basic rules in mind for myself when programming php

1. Always use full open tags <?php and avoid short tags and/or asp style tags.

2. always make code clean and neat.

3. Always comment code well.

 

As far as sessions specifically I advise you to use php's basic built in session handling until you are very advanced because there can be a lot of security issues with custom session handling if you are not in full control of what you are doing.

Link to comment
https://forums.phpfreaks.com/topic/74070-programming-practices/#findComment-373971
Share on other sites

Me personally, those were all based on opinion.

I stick to all of those when I program.  It is especially helpful to me when I am working with

other developers and I know someone else is goign to look throug my code.  As for comments it'll help

you later when you come back to your code and need to make changes.

Link to comment
https://forums.phpfreaks.com/topic/74070-programming-practices/#findComment-374029
Share on other sites

You may want to look at Zend for PHP4 but for PHP5 it get techincal.

 

The PHP4 Zend custom sessions are very easy to use.

 

http://www.zend.com/zend/spotlight/code-gallery-wade8.php?article=code-gallery-wade8&kind=sl&id=4791&open=1&anc=0&view=1

 

 

Link to comment
https://forums.phpfreaks.com/topic/74070-programming-practices/#findComment-374036
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.