Recent Posts
thephpcode
Return To Blog Listing
thephpcode php code resource for all where we have code examples, cool techniques, tricks and sales of codes.
Recent Posts Tagged With 'speed'
file_get_contents() vs fread() - Speed Test and Benchmarking
File access is commonly found in any PHP application. Be it caching, or reading data from a file or what. Lately I've been wondering, whether the use of file_get_contents() over fread() is a good practice (i always prefer file_get_contents()).So this...
PHP speed up: Quote your strings
I've wanted to post this earlier, but i've been busy lately. So yeah, here's a tip off on how to speed things up for new or beginner php developers.You might have noticed, PHP error level by default is set to E_ALL & ~E_NOTICE, which means all errors...
Optimize your code: Keep functions out of statements!
It's always said that we should think out of the box. In any programming language, we should write functions out of certain statements statements.Consider this:<?php$arr = array(/* 10000 elements */);for($i = 0; $i < count($arr); $i++){ // ...}?&g...
PHP Arrays - End vs Indices
I've looked through the PHP Arrays function list lately while working on some php scripts that requires lots of interaction with Arrays. It came to me that the following 2 are the identical:$value = end($array);$value2 = $array[count($array)-1];But w...
Using single instead of double quotes in PHP
Today I was reading up on some articles on the web when I suddenly gave thought about the codes I have always been doing.The other day I was talking to my friend about using single or double quotes, and I persisted on using single quotes instead of d...
Speeding up conditional (IF/ELSE) statements
Do you know that conditional statements can be actually sped up if you use the appropriate statements and expressions?Take a look at the following 2 codes:<?phpif($test==5){print 't';}else{print 't2';}?>and<?php($test == 5) ? print 't' : pri...
Arrays Loop Benchmarking: foreach vs while
Yes yes, i am current obsessed with loads of PHP speed tests on my local machine. But today I worked on something interesting: foreach vs while loops for Arrays.Remember one of my posts titled "PHP Loop Benchmarking - WHILE vs FOR"? It talks about yo...
Echo vs Output buffer
Here I am again. Lately i've been working on my framework - Samstyle PHP Framework - and now i am here to share with you about Echo versus Output Buffering.Just today I have tested and proved why output buffering then echo is always better than a dir...
PHP Loop Benchmarking
I was very bored today, when I suddenly realised that I should do some benchmarking for PHP myself. I created a script (can be found at thephpcode pastebin: http://thephpcode.pastebin.com/f80e53fe) and run it on my xampp localhost.In the php benchmar...
