Posts

Showing posts from December, 2011

HTTP Headers in php

You can add headers to the HTTP response in PHP using the Header() function. Since the response headers are sent before any of the actual response data, you have to send these headers before outputting any data. So, put any such header calls at the top of your script. Redirection <?php header('Location: http://www.php.net'); ?> Setting a Last-Modified Header <?php header('Last-Modified: '.gmdate('D, d M Y H:i:s',getlastmod()).' GMT'); ?> Avoid all Caching <?php header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Expires: Mon,13 Jal 1980 05:00:00 GMT'); ?>

OOP Programming with php

Object Oriented programming requires a different way of thinking how you construct your applications. Objects enable you to more closely model in code the real-world tasks, processes and ideas that your application is designed to handle. You can think of a class as a blueprint for constructing an object, you can build multiple instance of an object. Lets start with creating a simple class example Class begins with keyword Class and followed by a name that isn't reserved word in php. It contains the definition of methods, members and attributes of a class. <?php class demo{ private $_name; public function __construct($name){ $this->_name = $name; } public function getName(){ return $this->_name; } public function setName($name){ $this->_name = $name; } public function __destruct(){ } } ?> The contructor to this object set class property 'name'.  The accessor method getname(), enabl...