Discussions
php programming tips tricks for performance improvement
Posted by roy123 • 5/18/09 • Subscribe to this Discussion [RSS] • Report This Topic
Topics: php performance improvement, php tips, php tutorials, programming tips, speed php
Hey all here I am going to write some tips to improve the performance of php script. You can also share your thaughts related to the performance improvement in php only.
------------------------------------------
Here are some of the Tips and tricks which can improve the speed and performance of your php script and may save your resources.(NOTE:I haven't tested all these tips but these are wildly used to improve the performance of the php script.)
1.string concatenation
------------------------
echo 'php', 'developer'; // saves overhead time for string concatenation.
echo 'foo' . 'bar'; // slower..
2.Interpolation
---------------------------
$variable = 'this is '.$another_var.' with me'; // faster
$variable = "this is $another_var with me"; // slower
User Comments
-
-
Here is a cool way to stop / avoid user to directly access to our configuration php scripts or important include files.
// this is first code block
if (realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME']))
{
exit('This file can not be accessed directly...');
}
// protected code below this.
complete post here > php-tuts.blogspot.com/2009/05/how-to-avoid-direct-access-to-file.html -
Roy, good tips - I didn't know about the double quotes slowing down the script.
Let me know when you have new posts or information to read. Throw up an avatar and stop by the boards more often I want to pick your php brain.
Thank you also for this code snippet.. is there a way for people(hackers) to d/l .php files from my server?? That would be troubling since the mysql database passwords are in those files.
-
-
Hey all can you help me in this discussion.
www.blogcatalog.com/discuss/entry/for-vs-foreach-php-which-is-good-for-arra...
Add Your Comment
Login to leave a message.


