Affiliate Programs
 
Search affiliate programs for: 
Affiliate Categories
» Affiliate Networks
» Ad Networks
» 2 Tier Programs
» Pay Per Sale
» Pay Per Lead
» Residual Income
» Datafeeds
» Multi Tier Programs
» Business Opps
» Other Programs

Newsletter
Get newly added affiliate programs by email. Enter your email here:
Article Categories
» Affiliate Marketing
» Business
» Ecommerce
» Hosting
» Marketing
» Sales
» Web Designing
» Webmasters
» SEO & Promotion
» Working At Home
» Other Articles
» Affiliate Glossary


Go Back   AffiliateSeeking Forum > Website Creation, Design & Maintenance > Programming > PHP

PHP Discuss about your PHP scripting issues or help others with their PHP scripting problems.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-21-2008, 11:23 AM
platter007 platter007 is offline
Junior Member
 
Join Date: Aug 2008
Posts: 0
platter007 is on a distinguished road
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.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-29-2008, 04:29 PM
mousee mousee is offline
Junior Member
 
Join Date: Aug 2008
Posts: 24
mousee is on a distinguished road
thanks for the tips. The last was unknown for me)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-10-2010, 07:18 AM
iimmdeepak iimmdeepak is offline
Senior Member
 
Join Date: May 2010
Location: Indore,india
Posts: 249
iimmdeepak is on a distinguished road
i was knowing this things thanks for sharing them also can u comment on the php security.
Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-13-2010, 04:39 PM
johngate2100 johngate2100 is offline
Junior Member
 
Join Date: Jun 2010
Posts: 22
johngate2100 is on a distinguished road
There are much information you have given here which is very helpful for me. You have a good knowledge of php. Keep it up.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-11-2010, 10:01 PM
craig.johnson84 craig.johnson84 is offline
Junior Member
 
Join Date: Nov 2010
Posts: 15
craig.johnson84 is on a distinguished road
Thanks for the good tips, but I'm not quite sure that isset() is faster than strlen(). Can you give me the source from where you have found it? Thank you in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-19-2011, 11:22 AM
sufalamtech's Avatar
sufalamtech sufalamtech is offline
Member
 
Join Date: Aug 2011
Location: India
Posts: 32
sufalamtech is on a distinguished road
Send a message via Yahoo to sufalamtech Send a message via Skype™ to sufalamtech
Really its very helpful for me to solve php programming code error.Thanks a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-19-2012, 06:38 AM
dianna dianna is offline
Senior Member
 
Join Date: Aug 2011
Posts: 347
dianna is on a distinguished road
PHP is based on an Object Oriented Architecture and most of its features, concepts and syntax are based on the C and Perl programming languages. Being an open source language, a large number of libraries and extensions, to extend its core functionalities, are available for download. PHP extensions include support for features such as XML parsing, compression utilities, dynamic generation of images, translation functions etc.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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 On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:40 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0
© 2004-2011 AffiliateSeeking. All rights reserved.