Re: Optimized PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



First rule: Premature optimization is the root of all evil.  Don't try to 
squeeze every millisecond out of your code unless it really needs it.  

That said, the conventional place to stick user account data is in the 
database.  The exact schema will vary, but you will want some sort of unique 
user id, a login name, a password, and "other stuff".  

For tracking active visitors, that's what the session is for.  Only store 
information in the session that should be persistent only for one visit.  
That will probably include the active user id plus whatever else you need.  

You also probably don't want to use the default session save handling, as it 
is not very robust.  Instead, write your own session handling functions and 
save the session data to the database.  That will give you better security, a 
more robust and extensible system, and in some cases even a performance 
boost.  See:

http://www.php.net/manual/en/function.session-set-save-handler.php

On Wednesday 03 October 2007, ashish.sharma wrote:
> Hello All,
>
> I am working on PHP from quite some time. I am pretty much comfortable in
> writing PHP code but I always want that I should write good, quality code.
> For this I always look for the best practices which other developers uses
> and implement and I am writing this for the same reason as I would like to
> know how can i code a good, optimized PHP code. What are the areas where I
> can optimize my code more to avoid extra consumption of resources h/w or
> s/w. What are the best practices I can follow to optimize my code to
> increase the speed and performance of my application and to reduce down the
> memory consumption. For example ..
>
> In an application where I am having some different settings for each of the
> user/visitor, then what will be the best approach of doing this? Should I
> keep all the settings in sessions or should i create an xml/ini file for
> each user and call that in the bootstrap file (at runtime, on the basis of
> the the User) to pick the settings of that user.
>
> These are the kind of questions for which I always have to think. So, can
> anyone suggest me some source / article / reference from where I can find
> the solutions of such of my problems.
>
> Looking forward for your suggestions ..
>
> Thx to all ..
>
> Ashish


-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux