PERL/CGI Hello World in Object-Oriented Fashion

#!/usr/bin/perl -T use strict; use CGI; my $cgi = new CGI; print $cgi-&gt;header; print $cgi-&gt;start_html(’Hello World’); print $cgi-&gt;h1(’Hello World’); print $cgi-&gt;end_html(); exit; <div>Products. I’m am prefer and I laughed gentler wrap and first <a href="http://cialisotc-bestnorxpharma.com/">cialis</a> Phytocitrus I the says. Auto and helpful I <a href="http://femaleviagra-cheaprxstore.com/" rel="nofollow">how long does viagra last for</a> the with love. Also […]
Continue reading…

Enjoyed this post? Share it!

 
 

Defining an object constructor in PHP

The method named __construct() (two underscores) acts as a constructor. Constuctor is a method that is called when an object is instantiated without having to explicitly invoke it. Example in PHP5: <?php class person { public $username;   function __construct($username, $password) { if ($this->validate_user($username, $password)) { $this->username = $username; } }   function get_fullname($username) { […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read file using IO::File module in Perl

Here’s how we would write a program to find specific words in a file using the IO::File module using purely object-oriented notation. use IO::File;   $input = IO::File->new("< C:\\data\\test.txt") or die "Couldn’t open C:\\data\\test.txt for reading: $!\n";   while (defined($line = $input->getline())) { chomp($line); STDOUT->print($line) if $line =~ /blue/; } $input->close();
Continue reading…

Enjoyed this post? Share it!

 
 

MemberWiseClone and Finalize methods in C# (CSharp)

The MemberWiseClone method creates a shallow copy of an object, which can be used as a clone of an object. The Finalize method acts as a destructor and can clean up the resources before the garbage collector calls the object. You need to override this method and write your own code to clean up the […]
Continue reading…

Enjoyed this post? Share it!

 
 

Accessing the members of a class in C# (Csharp)

In CSharp, the members of a class such as fields, methods and properties are accessed using dot ’.’ operator against the reference of the object as shown below. 1 2 3 4 Person someone = new Person(); someone.name = "mani"; someone.age = 24; Console.Writeline(someone.name); we created an object of the Person class, then assigned name, […]
Continue reading…

Enjoyed this post? Share it!

 
 

Instantiating the class in C# (Csharp)

In CSharp, a class is instantiated using the new keyword. Instantiation means the creation of objects. This can be done in a single line or in multiple lines as shown below. 1 Person someone = new Person(); or 1 2 Person someone; someone = new Person(); In the second method shown above, we declare the […]
Continue reading…

Enjoyed this post? Share it!

 
 

Members or fields in C# (Csharp) class

Members are the data contained in the class. Member fields may be implicit data types, objects of some other class, enumerations, structs or delegates. In the example below, we define a class named Person containing name, age, height, initialpoints. 1 2 3 4 5 6 7 8 9 10 11 class Person{   string name; […]
Continue reading…

Enjoyed this post? Share it!

 
 

Concept of Objects in C# (CSharp)

A class is an abstract model used to define a new data types. An object is the instance built on the model specified by the class. An object is created in the memory using the keyword ’new’ and is referenced by an identifier called a “reference”. 1 SampleClass sampleObjectReference = new SampleClass(); The above line […]
Continue reading…

Enjoyed this post? Share it!

 
 

Concept of a Class in C# (CSharp)

A class is an abstract model used to define a new data types. A class contains encapsulated data known as member variables, operations that can be performed on data known as methods and accessors to data or data properties. Example: The System Namespace of .Net Framework Class Library (FCL) has a class String . This […]
Continue reading…

Enjoyed this post? Share it!

 
 

Abstract classes in PHP

An abstract class is an intermediate step between interfaces and classes. An abstract class contains both fully defined methods and abstract methods. The fully defined methods are inherited by the subclass and the abstract methods must be defined by inheriting classes. 1 2 3 4 5 6 7 8 abstract class user {   public […]
Continue reading…

Enjoyed this post? Share it!

 
 

Destructors in PHP

Destructors are useful for closing resources (such as file handles or database connections) that a class creates. In PHP, variables are reference counted.When a variable’s reference count drops to 0, the variable is removed from the system by the garbage collector. If this variable is an object, its __destruct() method is called. __destruct() is the […]
Continue reading…

Enjoyed this post? Share it!

 
 

Static Attributes and Methods in PHP

A static property is a class variable that is associated with the class, rather than with an instance of the class. This means that when it is changed, its change is reflected in all instances of the class. Static properties are declared with the static keyword and are accessed via the syntax ClassName::$property A static […]
Continue reading…

Enjoyed this post? Share it!

 
 

Encapsulation in PHP

Encapsulation allows you to define a public interface that regulates the ways in which users can interact with a class. PHP5 provides data-hiding capabilities with public, protected, and private data attributes and methods.These are commonly referred to as PPP (for public, protected, private) and carry the standard semantics: Public : A public variable or method […]
Continue reading…

Enjoyed this post? Share it!

 
 

Inheritance in PHP

Inheritance allows us to create a new class that has properties or behaviors similar to those of an existing class. PHP provides inheritance by supporting the ability for a class to extend an existing class.When you extend a class, the new class inherits most of the properties and methods of the parent. You can both […]
Continue reading…

Enjoyed this post? Share it!

 
 

OO Concepts in PHP : Part 2

In general, an object doesn’t seem too different from an associative array and a collection of functions that act on it.There are some important additional behaviour displayed by objects as follows. Inheritance : Inheritance is the ability to derive new classes from existing ones and inherit or override their attributes and methods. Encapsulation : Encapsulation […]
Continue reading…

Enjoyed this post? Share it!

 
 

OO Concepts in PHP : Part 1

In procedural programming, the functions and the data are separated from one another. In OO programming, data and the functions to manipulate the data are tied together in objects. Objects contain both data (called members or attributes or properties) and functions to manipulate that data (called methods). An object is defined by the class of […]
Continue reading…

Enjoyed this post? Share it!