Here are some tips that can make your PHP website faster-

Use Caching
Always use catching results. It will help you to catch your data many times. Like, your database results. For this you can use Memcache . A standard template system like Smarty can also help you.
Access object properties directly

Many times some conventional programming practices make our page slow. A typical example of setter and getter methods. For example we have a class like-


class mydata
{
public $name = '';

public function setName($name) {
 $this
->name = $name;
 
}

 
public function getName() {
 
return $this->name;
 
}

}
$obj = new mydata();
$obj
->setName('Smith');
echo $obj->getName();
?>
Here setter and getter methods have no use except holding the data. We can avoid this by simply using -


$obj = new mydata();
$obj
->name = 'Smith';
echo $obj
->name;


Do Not Use Extra Variables 

Sometime we use extra variables for our understanding , which occupies double memory in our program.
For example lets have a look on following code-


$str=$_POST[‘data’];
$temp=fun($str); //some function
echo $temp;
?>
Now , suppose your $_POST[‘data’] contains 512 KB or memory , so the program will occupy the same memory for $temp and for $str also. Obviously it will make your page slow. You can simply avoid it by-



echo fun($_POST[‘data’]);