All posts by Pramod T P


The fpassthru() function reads all data from the current position in an open file, until EOF, and writes the result to the output buffer.

This function returns the number of characters passed or FALSE on failure.



$fp = @fopen(“test.txt”, “r”);





It return the current key and value pair from an array and advance the array cursor


 echo "<pre>";
 $array = array("php", "asp", "jsp", "as", "js");
 $array2 = each($array);


[1] => php
[value] => php
[0] => 0
[key] => 0



The array_rand() function returns a random key from an array, or it returns an array of random keys if you specify that the function should return more than one key.


 $array = array("PHP", "ASP", "JSP");
 $keys = array_rand($array, 2);
 echo $array[$keys[0]];





It  checks if the given key or index exists in the array


 $array = array('PHP' => 1, 'JSP' => 4);
 if (array_key_exists('PHP', $array)) echo "The 'PHP' element is in the array";


The ‘PHP’ element is in the array



JSON or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship to JavaScript, it is language-independent, with parsers available for many languages.

A format to represent any PHP type, except a resource, that can be used later in JavaScript

The JSON format was originally specified by Douglas Crockford, and is described in RFC 4627. The official Internet media type for JSON is application/json. The JSON filename extension is .json.

The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML.


Magento is an e-commerce platform created on open source technology, which provides online merchants with an exceptional flexibility and control over the content, look and functionality of their e-commerce store.

Magento is an open-source content management system for e-commerce web sites. The software was originally developed by Varien Inc., a US private company headquartered in Culver City, California, with assistance from volunteers.

Varien published the first general-availability release of the software on March 31, 2008, under the name Bento. Roy Rubin, former CEO of Varien, later sold a substantial share of the company to eBay, which is now the sole owner.

According to research conducted by aheadWorks in October 2014, Magento’s market share among the 30 most popular e-commerce platforms is about 30%.

Magento employs the MySQL relational database management system, the PHP programming language, and elements of the Zend Framework. It applies the conventions of object-oriented programming and model-view-controller architecture. Magento also uses the entity–attribute–value model to store data.



Namespaces is a method with which we can group variable,function or objects so that we can have more than one variable or function or object with same name .

Namespaces were introduced into PHP from version 5.3 onwards


• Helps to prevent accidentally re-defining functions, classes, constants, …
• Avoids having to use long, highly descriptive class names
• Constants, classes, traits, interfaces and functions are affeced by the use of namespaces
• Create sub-namespaces to sub-divide a library

Declaring Namespaces

• Must declare the use of namespaces with the keyword “namespace” at the beginning of the code file (right after <?PHP)
• Use one namespace per code file (best practice)
• Unless a namespace is defined, constants, classes, functions, traits and interfaces are defined with the global namespace
• Within a namespace qualifying with a “\” references the global namespace
• Once code elements within a single namespace are defined, they can be used in other php files


 namespace php;
 class php
 public function phpcodez()
 echo 'Function1 <br />';
 namespace codez;
 class codez
 public function phpcodez()
 echo 'Function2 <br />';

$phpcodez = new phpphp();

$phpcodez = new codezcodez();



A function is a group of statements that will do certain tasks.

Why Function

When we develop a module in a project , we may need to implement certain tasks(block of statements ) more than once . Writing same block of codes more than once is not at all a good practice . Instead we can give a name to that block and can use them whenever necessary . When we define a block with a name , it is known as function .

• Blocks of code that execute in isolation (and local scope) that perform an action
• Function names are case-insensitive; defined in global scope
• Can be referenced before being defined unless function conditional
• Types: built-in (php supplied); user-defined; externally provided

General Format

function funation_name(){
echo “Error”; // can be on or more lines of statements

function – a keyword
funation_name – Any desired name(Should be meaningful)

Once the function is desfined , You can can invoke it by calling its name

<?php funation_name(); ?> // It will print the text “ Error”

A function can have arguments . When a fuction is define using arguments in it , we should pass the values when calling the it .

Example :
function function_sum($a,$b){
echo $a+$b;

<?php function_sum(7,8); ?> // It will display 15 as the result .

Note : We should not use any Builtin function name as the function name


Safe mode

Safe mode is a diagnostic mode of a computer operating system (OS). It can also refer to a mode of operation by application software. Safe mode is intended to fix most, if not all problems within an operating system. It is also widely used for removing Rogue security software.

The PHP safe mode is an attempt to solve the shared-server security problem. It is architecturally incorrect to try to solve this problem at the PHP level, but since the alternatives at the web server and OS levels aren’t very realistic, many people, especially ISP’s, use safe mode for now.

  • Limit the execution of shell commands
  • Limit access to system environment variables
  • Limit the paths from which PHP can include files using include or require


The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP.


  • Supports 12 different databases
  • Object Mapping
  • Supports prepared statements
  • Supports multiple statements
  • Object oriented interface
  • Named parameters
  • PDO has built-in support for Large Objects (LOBs).
  • When something goes wrong, PDO can throw an instance of its own exception class.
  • PDO does not emulate missing database features.
  • Placeholders within PDO prepared statements need not be named.