how can i optimize my php code ?

by 10 replies
12
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 ?
#programming #code #optimize #php
  • 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.
  • okay..so is this way to optimize the code?
    • [1] reply
    • 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.
      • [ 1 ] Thanks
  • okay... Thanks for sharing your thoughts..
  • 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.
    • [ 1 ] Thanks
  • 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
    • [ 1 ] Thanks
    • [1] reply
    • 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.
      • [1] reply
  • 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.
  • 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.
  • Banned
    [DELETED]

Next Topics on Trending Feed

  • 12

    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 ?