Experience Advertising Forums  
  (#1) Old
platter007 Offline
Newbie Poster
platter007 is an unknown quantity at this point
 
Posts: 1
Join Date: Aug 2008
Rep Power: 0
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq
Default PHP Tips And Tricks - 08-21-2008

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.
   
Reply With Quote


Sponsored Links
Join the Best Performing & Highest Paying Affiliate Programs!
  (#2) Old
sherytiger Offline
Tiger Of EXPADV
sherytiger is a jewel in the roughsherytiger is a jewel in the roughsherytiger is a jewel in the roughsherytiger is a jewel in the roughsherytiger is a jewel in the rough
 
sherytiger's Avatar
 
Posts: 656
Join Date: Dec 2007
Location: In This Normal World
Rep Power: 100
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq
Default 08-21-2008

Bunch of Thanks for the above given tips!
  Send a message via MSN to sherytiger  
Reply With Quote

  (#3) Old
angelina.maben Offline
Newbie Poster
angelina.maben is an unknown quantity at this point
 
Posts: 43
Join Date: Sep 2008
Rep Power: 0
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq
Default 09-04-2008

I understood the strln funtion. What about the isset() ?? Is it a variable and for what is it used?
   
Reply With Quote

  (#4) Old
abhikerl Offline
Newbie Poster
abhikerl is an unknown quantity at this point
 
Posts: 11
Join Date: Sep 2008
Rep Power: 0
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq
Default very useful - 09-12-2008

thanks for the explanation, it's very useful
   
Reply With Quote

  (#5) Old
Passion Offline
Newbie Poster
Passion is an unknown quantity at this point
 
Posts: 1
Join Date: Aug 2008
Rep Power: 0
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq
Default 10-10-2008

Great Tips..Thanks for it
   
Reply With Quote

  (#6) Old
philip51 Offline
Newbie Poster
philip51 is an unknown quantity at this point
 
Posts: 28
Join Date: Sep 2008
Rep Power: 0
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq
Default 10-13-2008

That was a nice tips I have read it a while ago thanks.
   
Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
My PPC Marketing Tips sherytiger PPC Forum 5 4 Weeks Ago 08:33 PM
Internet Safety - My Favorite 7 Tips sherytiger Forum Lobby 15 10-10-2008 04:43 PM
Tips for Clickbank Affiliates jasonxxx102 Affiliate Marketing Forums 1 09-16-2008 07:39 PM
Tips on Domain Name Choice sherytiger Internet Marketing Forums 7 08-22-2008 05:39 PM
AdSense tips that you might have missed out on sherytiger Affiliate Networks 4 01-09-2008 05:12 AM



Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
vBulletin Skin developed by: Seo Consultancy
© 2007-2008 Experience Advertising Inc. All Rights Reserved


Our Clients
Image
Image Image
Image
Image
Image Image
Image
Image
Image Image
Image
Image
Image