Go Back   Webmaster Forums UK SEO SEM Webmaster Community Forum - UKWW > Web Design and Website Development > Programming > PHP Forum
Register FAQ Members List Downloads Calendar Today's Posts Webmaster Resources Webmaster Blogs
 
 

PHP Forum PHP related discussion, help, tips and tutorials.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-21-2008, 11:09 AM
Junior Member
1 posts this year. needs some grease!
New user, who has not interacted much yet.
Last months UKWW Tokens: 4
 
Join Date: Aug 2008
Posts: 1
Thanks: 0
Thanked 3 Times in 1 Post
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Default PHP Tips And Tricks

PHP Tips And Tricks

File Access Optimization
When you need to including file, please recheck file content that will be use. If file is

not contains PHP codes, use readfile() function to increase performance.
Because files that including with readfile() does not parsing by PHP. It will be different

with construction language include() and require(), and files will be evaluated before.

Consequence from using readfile() is increase attack risk. This risk will be happen when

accessing file from URL.

Solution for the attack risk is by using File Handling.


Using echo
Echo allowed gives more than one string as parameter. Using some parameters are going to

more faster than blending some variables into a parameter.

$a = ‘Hello’;
$b = ‘Word’;
echo ‘Say ‘ .$a. ‘ to ‘ .$b’;
//more faster
echo ‘Say ‘ , $a, ‘ to ‘, $b’;


Checking string size

We usually using strlen() function to check the string size. The fast way to checking string

size is using isset().

if (strlen($str) <>
echo ‘String must be at least 5 chars’;
}

if (!isset($str{5})) {
echo ‘String must be at least 5 chars’;
}

isset() needs more little time than strlen() because isset() is construction language.


Avoid using Large String Concatenation
When do concatenation string, avoid uniting with large size string. It can obstructing code

execution that really can display more faster.

//large string concatenation
$title = ‘title’;
$body = ‘…a very large block…’;
echo “Subject: $title\n\n$body”;

//avoid large string concatenation
$title = ‘title’;
$body = ‘…a very large block…’;
echo “Subject: $title\n\n”;
echo $body;


Boolean data type
PHP is allowing to write Boolean data type with uppercase or lowercase. But, writing with

lowercase is more faster than uppercase. When found a constant, PHP do lookup hash constant

name.

if ($var = TRUE) {
...
}

//this is more faster
if ($var = true) {
...
}

When using a Boolean value, 1 and 0 are more faster than true and false.


Avoid space in your code
In this tip and trick, I’m going to explain how to make code optimization on your

application. The main purpose of this code optimization is to get more faster code

execution. The elementary key is by writing code effectively and efficiently. Because PHP

codes going to execute every time they are requested.

Avoid space in your code

Avoid using many spaces ( ) is a good thing. Every space is 1 byte and every tab (\t) is 1

byte. When you’re using four spaces, you’ve been use 4 bytes. It’s more effective if you’re

using a tab (\t).


Print Output
PHP is giving some sting functions to printing output into browser and we are often using

print() and echo() function. Both of those functions are not real function but a language

construction. print() and echo() function have same goal, but there are some essential

different that must to pay attention.

Print() function behavior like the other function in common and having return value integer

1. Thus, print() can used as part of expression which more complex. Meanwhile, echo() is

able to accept more than one parameters all at once, and does not having return value.

print() ‘string 1’;
echo ‘string 1’;
// using some parameters
echo ‘string 1’, “string 2”, ‘…’;

echo() function string will execution more faster than print(). This differentiate caused by

will return status (integer) which expose what process has done or not.

On the other side, echo() just displaying output only and do anything. At implementation,

return value status from using function string almost never needed.
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
The Following 3 Users Say Thank You to platter007 For This Useful Post:
deluxdon (08-21-2008), eugen (08-21-2008), gkd_uk (08-21-2008)
  #2 (permalink)  
Old 09-10-2008, 09:27 PM
Junior Member
12 posts this year. the lights are on!
User is on their way up.
Last months UKWW Tokens: 10
 
Join Date: Sep 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Default

Thanks for the tips bro
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 10-03-2008, 11:44 AM
Junior Member
13 posts this year. the lights are on!
User is on their way up.
Last months UKWW Tokens: 12
 
Join Date: Oct 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Default

quite good..........keep it up
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 10-07-2008, 02:18 AM
Junior Member
16 posts this year. the lights are on!
User is on their way up.
Last months UKWW Tokens: 24
 
Join Date: Oct 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Default

Great tips, keem em coming!

Thanks
Digg this Post!Add Post to del.icio.usStumble this Post!Wong this Post!
Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Webmaster Resources
UK WW SEO Tools
Find UK Hosts
 
The Forum Rules
Forum Rules - MUST READ
 
Site Of the Month
BizzFace
Nominate site of the month
 
Tag Cloud
43. wholesale adsense ready apple iphone 16gb apple iphone 16gb 3g articles article writer australia web hosting beauty cash casino cheap clothes communications content custard media database dgital camerals domain name english teacher fantasy football fantasy football league fittness football league free handbags home income instant jewelry links link sale medical health money money making online music natural health news nokia n96 16gb one way links online online shop poker professor quality links replica sam allcock seo social networking sony vaio laptop sunglasses technology the medical plus themes tutor verbalized wallet wallets wanted web hosting widget ready wordpress xmas offer

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:57 AM.

UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons.
Subscribe to our feeds   Subscribe to our feeds

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0