Results 1 to 7 of 7

Thread: PHP Code

  1. #1
    Ah, Mrs. Peel! mike_w's Avatar
    Join Date
    Oct 2003
    Location
    Hertfordshire, England
    Posts
    3,326
    Thanks
    3
    Thanked
    9 times in 7 posts

    PHP Code

    This probably won't get (m)any replies, but I'll ask anyway!

    Does anybody have any tips on the best way to write PHP code, particularly on the speed of the code? For example, is it better to store a date fully (e.g. Saturday 5th November 2005) in MySQL, or store it as a datetime, and then get PHP to convert it to the format I want? (I have it the latter way right now - better in case I want to change it?) At the moment, pages are generated in up to 0.5 seconds.

    Thanks

    Mike
    "Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."

  2. #2
    Gaarrrrr! Dav0s's Avatar
    Join Date
    Aug 2005
    Location
    Bristol
    Posts
    1,442
    Thanks
    1
    Thanked
    3 times in 3 posts
    it will be quicker to use a timestamp and convert using date()

  3. #3
    HEXUS.social member Agent's Avatar
    Join Date
    Jul 2003
    Location
    Internet
    Posts
    19,185
    Thanks
    739
    Thanked
    1,614 times in 1,050 posts
    I did a simple caching script not too long back for my mini CMS.
    Ive just found this which looks pretty good at explaining it. Im pretty sure thats all fairly basic to you, but its worth looking at.

    http://www.sitepoint.com/blogs/2005/...optimizations/ also has some info on " vs ' - not a massive difference though.
    The odd thing at http://www.e-gineer.com/v1/articles/...s-paradise.htm too.

    Although, when i was trying to optimise, nearly all the [significant] time savings came from better SQL querys and the database side of things.
    Quote Originally Posted by Saracen View Post
    And by trying to force me to like small pants, they've alienated me.

  4. #4
    Bigger than Jesus Norky's Avatar
    Join Date
    Feb 2005
    Posts
    1,579
    Thanks
    1
    Thanked
    8 times in 8 posts
    Quote Originally Posted by Davos
    it will be quicker to use a timestamp and convert using date()
    That's what I do. If you start using pre-formatted dates you end up having to parse them using regex etc. if you want the data from them.

  5. #5
    Senior Member
    Join Date
    Apr 2005
    Location
    Bournemouth, Dorset
    Posts
    1,631
    Thanks
    13
    Thanked
    2 times in 2 posts
    i also use the timestamp function on the mysql side and just tell it how to format it in the table so i dont have to write any code for it in the front end.

  6. #6
    Ah, Mrs. Peel! mike_w's Avatar
    Join Date
    Oct 2003
    Location
    Hertfordshire, England
    Posts
    3,326
    Thanks
    3
    Thanked
    9 times in 7 posts
    Quote Originally Posted by Agent
    I did a simple caching script not too long back for my mini CMS.
    Ive just found this which looks pretty good at explaining it. Im pretty sure thats all fairly basic to you, but its worth looking at.
    Fairly basic? I've barely started learning! The caching looks quite good - I'll try implementing that at some point.

    Although, when i was trying to optimise, nearly all the [significant] time savings came from better SQL querys and the database side of things.
    Interesting... anybody have any tips for the MySQL side of things?
    "Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."

  7. #7
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts
    if your worried about performance, take a look at Zend optomiser, or better yet phlanger (PHP compiler for .net environments).

    if you really must have performance, then don't use PHP, its showing its age now, but its great for quickly nocking up small sites.
    throw new ArgumentException (String, String, Exception)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sony CDX-M650 Car Stereo Code
    By ikonia in forum Consumer Electronics
    Replies: 4
    Last Post: 16-10-2005, 06:19 PM
  2. Online Glossary (php)
    By Dorza in forum Software
    Replies: 7
    Last Post: 16-09-2005, 08:35 PM
  3. Efficiency of PHP code
    By Kezzer in forum Software
    Replies: 41
    Last Post: 16-03-2005, 07:49 PM
  4. Linux code help!
    By nvening in forum Software
    Replies: 18
    Last Post: 26-02-2005, 12:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •