+ Reply to Thread
Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By finalheatsmix
  • 1 Post By misson

Thread: PHP Optimization Techniques?

  1. #1
    finalheatsmix is offline x10Hosting Member finalheatsmix is an unknown quantity at this point
    Join Date
    Jun 2011
    Location
    Canada
    Posts
    1

    PHP Optimization Techniques?

    So I was wondering what are some good techniques to optimize PHP code for the fastest execution. I only technique I know is changing all lines of PHP code to 1 line execution. As far as I know that is one of the worst ways to optimize PHP because you need to make 2 copies of the PHP files.
    dinomirt96 likes this.

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP Optimization Techniques?

    You should be less concerned with optimization and more concerned with algorithmic efficiency and development practices. As the great Knuth once wrote, "premature optimization is the root of all evil." Optimization is one of the last things to attempt, after your software has matured and the code base is fairly stable. At that point, if your software runs too slowly you profile the code to see where it's running slowest and focus on optimizing that section.

    Quote Originally Posted by finalheatsmix View Post
    I only technique I know is changing all lines of PHP code to 1 line execution.
    What do you mean by this? I have the sneaking suspicion it isn't an optimization.
    karimirt47 likes this.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    slynn12335 is offline x10Hosting Member slynn12335 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    1

    Re: PHP Optimization Techniques?

    Quote Originally Posted by misson View Post
    You should be less concerned with optimization and more concerned with algorithmic efficiency and development practices.
    Exactly. The people developing PHP are already doing their best to optimise processing so it's up to the efficiency of the actual code you are writing. Any glaring performance hits will most likely be a section of your code that's doing a lot more than you need it to without you realising. One quick tip or example (presuming you're using MySQL) is to not SELECT *. Select only what you need (SELECT id,username et cetera).

  4. #4
    grsubs48 is offline x10Hosting Member grsubs48 is an unknown quantity at this point
    Join Date
    Jul 2011
    Posts
    10

    Re: PHP Optimization Techniques?

    Quote Originally Posted by slynn12335 View Post
    is to not SELECT *. Select only what you need (SELECT id,username et cetera).
    I'm just browsing some threads here and picking up some useful information. I would have been using SELECT * WHERE field = ? then selecting my fields. I didn't know that you could just select the fields that you required. I don't find the 3k odd pages of the mysql manual very inviting, paticularly, when the only way of reading it is by scrolling thru a pdf file.

    Glad to be able to pick up on those little titbits

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP Optimization Techniques?

    Quote Originally Posted by grsubs48 View Post
    I don't find the 3k odd pages of the mysql manual very inviting, paticularly, when the only way of reading it is by scrolling thru a pdf file.
    It's not only available as a PDF. The MySQL manual is available in HTML and can be searched using the MySQL site's searches (there's a site wide search and another that searches only the manual) or with Google. There are plenty of other reference sites available online, but if you're doing any sort of development, you need to learn to read the official technical documentation.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Replies: 2
    Last Post: 07-25-2011, 05:53 AM
  2. Replies: 3
    Last Post: 06-27-2011, 09:25 AM
  3. SEO Techniques/tricks ??
    By careerbridge in forum Off Topic
    Replies: 3
    Last Post: 03-08-2007, 06:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers