Results 1 to 13 of 13
-
03-31-2011, 09:57 PM #1Web Hosting Master
- Join Date
- Feb 2011
- Posts
- 792
PHP with spaces or without spaces
I am trying to optimize my PHP scripts to be faster and use less resources. Do spaces and line breaks in the PHP code itself increase or decrease speed and/or resource usage?
My personal blog -- rubiverse.net
-
03-31-2011, 10:50 PM #2Junior Guru
- Join Date
- Jul 2010
- Posts
- 202
Newp.
If you were concerned about that the smart thing to do would be to use an opcode cache like xcache or something and it'd render it irrelevent, but short of it being extra data to read through which obviously has an effect - but minimal - no.
-
04-01-2011, 04:00 AM #3AWS Developer GCP AZURE Devops
- Join Date
- Dec 2002
- Location
- India
- Posts
- 1,433
PHP with spaces or without spaceChris, Developer/Programmer,
https://www.chrisranjana.com/
Php laravel developers, Node Python developers,
AWS Certified | Python developers | Nodejs Developers | Devops
-
04-01-2011, 08:18 AM #4Junior Guru
- Join Date
- Oct 2010
- Posts
- 220
Check this out :
http://www.joomlaperformance.com/art...s_43_14_2.html
I found some interesting things there like:
echo is 5% faster than print()
'String' is 0.26% faster than "String"
-
04-01-2011, 08:41 AM #5Web Hosting Evangelist
- Join Date
- Sep 2004
- Location
- Cluj-Napoca, Romania
- Posts
- 504
Is it the PHP itself speed execution that you want to optimize?
Database queries are usually the ones that are slowing PHP scripts and optimization for this is usually done on the database side and not in the PHP code.
-
04-03-2011, 10:57 PM #6Junior Guru Wannabe
- Join Date
- Apr 2011
- Location
- Melbourne
- Posts
- 93
Use an opcode cache, optimise your database queries and try to include as few files as possible to reduce disk IO. Those three in themselves will create genuine performance gains... removing spaces from a file won't even make a blip on the radar.
-
04-03-2011, 11:18 PM #7Junior Guru
- Join Date
- Jul 2010
- Posts
- 202
Think I said that already.
-
04-04-2011, 12:20 PM #8Web Hosting Master
- Join Date
- Feb 2011
- Posts
- 792
My personal blog -- rubiverse.net
-
04-04-2011, 01:25 PM #9Junior Guru
- Join Date
- Jul 2010
- Posts
- 202
If they do any amount of PHP hosting at all it's highly recomended - maybe you can suggest they do and get some brownie points
-
04-04-2011, 02:29 PM #10Web Hosting Master
- Join Date
- Jan 2004
- Posts
- 593
Half the hosts out there use SuPHP. They don't have much of a choice.
As for optimization. It's all in the coding techniques and your knowledge of the built in functions that php provides.
Spacing is ignored as are comments, however, the smaller the file the faster it will be read.
I suggest looking into a few books by Larry Ullman. He is a great author and easy to follow.
-
04-04-2011, 02:42 PM #11Junior Guru
- Join Date
- Jul 2010
- Posts
- 202
And half don't
Seriously though that's an issue but it's worth mentioning.
Opcode caches are useful for a whole bunch of issues that can't be solved with code optimisation alone.
-
04-04-2011, 02:45 PM #12Web Hosting Master
- Join Date
- Jan 2004
- Posts
- 593
-
04-04-2011, 03:34 PM #13Web Hosting Master
- Join Date
- Feb 2011
- Posts
- 792
My host uses LiteSpeed lsapi php suexec, if that helps.
My personal blog -- rubiverse.net
Similar Threads
-
PHP Function spaces not allowed(Newbie question)
By bambinou in forum Programming DiscussionReplies: 5Last Post: 01-22-2011, 01:37 PM -
PHP: Breaking long text (w/o spaces)
By krissauquillo in forum Programming DiscussionReplies: 4Last Post: 12-22-2007, 12:06 AM -
PHP/MySQL script keeps adding blank spaces to the database.
By Mark226 in forum Programming DiscussionReplies: 8Last Post: 09-26-2005, 04:29 AM -
Ad spaces available
By Dec in forum Other Offers & RequestsReplies: 2Last Post: 11-01-2003, 10:30 PM -
php help, removing spaces
By matt2kjones in forum Programming DiscussionReplies: 15Last Post: 09-29-2003, 02:07 AM