Some Significant Features of PHP5

Web developers and designers have known PHP for many years. The ‘PHP Hypertext Preprocessor’ has changed the entire dimension of the world of websites since its inception in the year 1994 by Rasmus Lerdorf. This language helps in server-side scripting that is embedded into HTML, which could be smoothly integrated with some commonplace databases like MySQL, Oracle, SQL server etc. Some supported protocols are IMAP, POP3, and LDAP. Some features are as follows:

i) Efficiency

ii) Simplicity

iii) Flexibility

iv) Security

v) Familiarity

Latest Features Of PHP5

PHP5 has following advancements over PHP4:

a) Features of OOPs

b) XML

c) MySQL

Supporting guards for the above-mentioned features have been totally revamped. PHP5 has overcome limitations faced by earlier versions. In addition, there are various other new additions, which are as follows:

Extensive Support Mechanisms For OOP:

Now onwards PHP 5 helps a developer with following concepts of Object Oriented Paradigm.

a) Constructors:

Developers can utilize constructors inside a class with the help of PHP5. As you know, the constructors are called upon for creating new class instances. Sample example of constructor code is as follows:

< ?php

class MyClass {

function __construct () {

print ” From Parent Class Constructor\n ” ;

}

}

class MySubClass extends MyClass {

function __construct () {

parent::__construct ();

print ” From SubClass constructor\n “;

}

}

?>

b) Destructors: PHP5 has introduced the destructor concept. When there is no reference to an object, destructor is called upon. Sample example of destructor code is as follows:

< ? php

class MyClass {

function __construct () {

print ” Calling from constructor\n “;

$this->name = ” MyClass “;

}

function __destruct () {

print ” Destructor Called. Destroying Class … ” . $this->name . “\n “;

}

}

$obj = new MyClass ();

?>

c) Access Modifiers: Three kinds of visibility types have been introduced through PHP5, which are Public, protected and Private.

d) Interfaces: Like OOP interfaces are important for PHP5 also. Sample example of destructor code is as follows:

<?php

// Declare the interface ‘iTemp’

interface iTemp

{

public function setSchool ( $name, $location );

public function getHtml ( $template );

}

// Implementing the interface

class myTemplate implements iTemp

{

private $vars = array ();

public function setSchool ( $name, $location )

{

$this-> locations[$name] = $var;

}

public function getHtml ($template)

{

foreach($this-> locations as $name => $value) {

$template = str_replace(‘{‘ . $name . ‘}’, $value, $template);

}

return $template;

}

}

?>

e) In addition support for static and, final properties and methods are provided by PHP5.

f) Abstract classes are supported in the same way as by other OOP based languages.

g) PHP 5 helps in to pass objects as a reference and not through values. So no more need to use ‘ampersand’.

h) Higher extensions for MySQL to tackle some problems faced by previous versions have been added like:

  • Prepared statements.
  • SSL connections.
  • Bound Input plus Output Parameters.
  • Functions based on multiple queries.
  • Object Oriented Interface is provided by MySQL with the help of PHP5.

i) PHP5 helps in to fix major issues reported by previous extensions, which are as follows:

  • It functions as a unified component.
  • Components are dependent on a single XML library.
  • Full compliance with the components and W3 standards.
  • Extremely efficient data processing.

j) One of the biggest advantages of PHP5 is inbuilt library functions for SQLite, a suitable database for smaller applications. Common database features are as follows:

  • Sub queries.
  • Transactions.
  • Triggers.

k) Enhanced implementation of SOAP: Simple Object Access Protocol or SOAP has become one of the integral components for web services and PHP5 supports SOAP clients with/without WSDL files (Web Service Definition Language). In addition, SOAP servers are also implemented in PHP5.

l) Iterators: Now this is a new feature added with PHP5. This iterator helps us to use ‘for each’ loop through various data structures like database results, directory listing and XML documents. Sample example of iterator is as follows:

<?php

foreach (new DirectoryIterator($path) as $file) {

print “$file\n”;

}

?>

m) To examine classes, methods and object attributes, reflection classes are used in PHP5.

n) Like Perl or AWK do command line versions are allowed for individual line processing in PHP5.

PHP training courses are offered at various institutions scattered across many countries. However, before enrolling, please check out whether or not they are teaching the latest version of PHP. The syllabus should always remain up-to-the-mark with latest additions.

I hope you learnt something new from this blog. Please share it with your friends and stay tuned for more updates. If you are an IT enthusiastic, and want to gather more knowledge, you can go through some of our blogs given below.

 

Ayan Sarkar

Ayan Sarkar is one of the youngest entrepreneurs of India. Possessing the talent of creative designing and development, Ayan is also interested in innovative technologies and believes in compiling them together to build unique digital solutions. He has worked as a consultant for various companies and has proved to be a value-added asset for each of them. With years of experience in web development, product managing and building domains for customers, he currently holds the position of the CTO in Webskitters Technology Solutions Pvt. Ltd.