how can i optimize my php code ?

10 replies
Hello everyone,

I know there is ample ways to optimize php code .. but i m in doubt .can we optimize our code through htaccess or can we optimize through code directly.If we optimize code through htaccess then how we can do ?
#code #optimize #php
  • Profile picture of the author ClicProject
    To optimize code is to rewrite parts of it to make it faster and more efficient. It has nothing to do with your htaccess file.
    {{ DiscussionBoard.errors[9239717].message }}
  • Profile picture of the author peter09
    okay..so is this way to optimize the code?
    {{ DiscussionBoard.errors[9243054].message }}
    • Profile picture of the author RobinInTexas
      Originally Posted by peter09 View Post

      okay..so is this way to optimize the code?
      There's no magic solution or tool to optimize php code, The only thing you can do is seek out books or tutorials on programming style and improve the way you write your code.
      Signature

      Robin



      ...Even if you're on the right track, you'll get run over if you just set there.
      {{ DiscussionBoard.errors[9243521].message }}
  • Profile picture of the author peter09
    okay... Thanks for sharing your thoughts..
    {{ DiscussionBoard.errors[9246756].message }}
  • Profile picture of the author blindapeseo
    Hello Peter.

    Code can only be optimized in the code itself.

    In the case of PHP scripts, this would be the PHP script itself as well as the .ini that might have to be changed to eliminate bottlenecks.
    {{ DiscussionBoard.errors[9247081].message }}
  • Profile picture of the author Nuke07
    Originally Posted by peter09 View Post

    Hello everyone,

    I know there is ample ways to optimize php code .. but i m in doubt .can we optimize our code through htaccess or can we optimize through code directly.If we optimize code through htaccess then how we can do ?
    If we talk about code optimization then you should follow up the given point that i do:

    - Separate inline js from php file
    - Comment every block of code that would help you in future development
    - unused function &variables should be removed
    - Unusual db connections should be removed that make multiple connections and make site heavier.
    - and more

    I hope this would help you.

    Nuke
    {{ DiscussionBoard.errors[9247414].message }}
    • Profile picture of the author peter09
      Originally Posted by Nuke07 View Post

      If we talk about code optimization then you should follow up the given point that i do:

      - Separate inline js from php file
      - Comment every block of code that would help you in future development
      - unused function &variables should be removed
      - Unusual db connections should be removed that make multiple connections and make site heavier.
      - and more

      I hope this would help you.

      Nuke
      On the third line you mentioned unused function and variable . through unset function can we removed unused variable and function.These are the tips if i follow so it could help me to optimize my code.
      {{ DiscussionBoard.errors[9250122].message }}
  • Profile picture of the author blindapeseo
    Well, outside of the PHP code, there is not a lot you can really do.

    The website output should be optimized, of course, this includes the HTML, using a cache and optimizing javascript calls.

    Optimizing the PHP code calls for a developer, though.
    There are no "one rule fits all" solutions here, as code has to be tailored to the needs.
    {{ DiscussionBoard.errors[9250486].message }}
  • Profile picture of the author Jason Stewart
    I would run your page through something like yslow to determine where your pain points are, then work on those. Maybe you are on a slow hosting provider? Maybe your script is slow? Before you optimize you have to figure out WHY it's slow.
    Signature

    Beat the competition with better long tail keywords:

    http://keywordstreamer.com

    {{ DiscussionBoard.errors[9250823].message }}

Trending Topics