PHP

PHP5 – Being Static

Class properties

This is another name for properties (or methods) declared static inside classes as these properties belong to a class and not to any instance/object.

The keyword ‘static’ is used to define static properties. Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

PHP4 Vs. PHP5 – What is New in PHP5? – Part 1

In PHP5, Zend engine has been rewritten to accomodate the new object oriented concepts. To start with, I will write on some functions that have been added to PHP5’s bag.

~ The access modifiers public/private/protected are introduced for methods and properties.

~ __construct() is used now instead of the function names in the name of the classes which makes it a uniform way of access

~ __destruct() function is now introduced which will run when an object is destroyed

Let us create a class to verify how the above concepts work.

class myBook{
 private var $bookTitle;
 function __constructor(){
     echo "Book object created in constructor";
  }
  function getBookTitle(){
      return $this->bookTitle;
   }
   function setBookTitle(){
      $this->bookTitle = "Hope Wins";
   }
   function __destruct(){
      echo "Object perishes now!";
   }
}
$myNewBook = new myBook();
// $myNewBook->bookTitle = "Truth about life"; 
// The above statement will return an error notice as the variable bookTitle declare private.
$myNewBook->getBookTitle();
$myNewBook = nothing;
unset($myNewBook);

~ Introduction of Abstract classes
An abstract class is a class that cannot be instantiated. But, you can inherit from an abstract class. If you want to declare a method as an abstract method, then you need to declare the class as an abstract class as well. When a method is declared abstract, then the inherting class will implement the method.

abstract class shape{

var $a, $b;

function calcSqFeet($a=0, $b=0){

if(!empty($a) && !empty($b){ echo "Square feet ".$a * $b); }

}

abstract function color();
}

class rectangle extends shape{
var $a, $b;

function __construct($a, $b){
$this->a = $a;
$this->b = $b;
}

function color(){
echo "Color of the shape is :" . "Red";
}

function getSqFeet($a, $b){
return calcSqFeet($a, $b);
}

}

// Declaration
$myShape->color();
$myShape->getSqFeet(3, 4);
Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

PHP: How to print a name of a class?

The following code helps identifying the name of the class with the usage of PHP constant __CLASS__

class myClass{

    function __construct(){
        echo "You are now inside class = ".__CLASS__;
    }

}
Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Object Handling in PHP4, PHP5

In PHP4, objects are passed by value and in PHP5 objects are passed by reference.

A sample program is shown below to get a better idea on this topic. Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

PHP: Personal Home Page

Personal Home Page – PHP Hypertext Processor

1997 – PHP/FI 2 solely handled by Rasmus

1998 – Zeev and Andi teamed up with Rasmus to give a new face to PHP by rewriting the core engine and a facility to interface with different technologies using API giving rise to the next version PHP 3. PHP 3 continuously parsed the scripts when they were getting executed. Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

What is the difference between a Cookie and a Session?

cookie is a text file that is stored on the client in name => value pairs to identify subsequent requests from the client by the server. Max. size of cookie file is 4k and it is stored on the client’s hard disk. Cookies are used as a mechanism to establish state and to track user behavior. Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Setup cakePHP framework – stable version 1.2.0.7962 released

CakePHP commonly known as ‘Cake’ is easy to install and faster to configure. It needs Apache (with mod_rewrite enabled), Php 4.3.2 or higher, MySQL/PostgreSQL/other ODBC, ADODB compliant databases.

XAMPP by ApacheFriends or MAMP has a complete installation of the above products which is an ultimate time saver. But, you should prefer installing each software individually in order to get a grip on the subject.

You can download the latest release from http://cakeforge.org/frs/download.php/695/1.2.0.7962.tar.gz Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

phpMyAdmin – visual interface for MySQL on Windows/Linux

phpMyAdmin is a web based interface to MySQL which is written using PHP for Administration of databases. Visual interface provided is intuitive and it saves time for the developers. (ver 3.1.1 is the recommended version as of this writing which runs on PHP 5/MySQL 5)

Step 1: First we need to check MySQL is installed by issuing the following command
[root@user Desktop]# which mysql

If you get …
/usr/bin/mysql
then, it is an indication that MySQL is installed in your machine. Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Kurinchi Calendar
April 2018
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
30