What is str_replace()

This function replace some characters with some other characters in a string , this function is case sensitive
syntax:- str_replace(find,replace,string);
find:-required,specifies the value to find
replace:-required,specifies the value to replace the value in find
string:-required,specifies the string to searched

str_replace()
<?php

echo str_replace(“world”,”india”,”hello world”);

?>

OUTPUT :
hello india… Read more

What is Final Keyword in PHP ?

PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

Final methods example
<?php

class BaseClass {
public function test() {
echo “BaseClass::test() called\n”;
}

final public

Read more

The basics of a Class in PHP

Basic class definitions begin with the keyword class, followed by a class name, followed by a pair of curly braces which enclose the definitions of the properties and methods belonging to the class.

A class may contain its own constants, variables (called “properties”), and functions (called “methods”).

Class
<?php

class

Read more

Properties of a PHP Class

Class member variables are called “properties”.They are defined by using one of the keywords public, protected, or private, followed by a normal variable declaration.In order to maintain backward compatibility with PHP 4, PHP 5 will still accept the use of the keyword var in property declarations instead of (or in … Read more

PHP Class Constants

It is possible to define constant values on a per-class basis remaining the same and unchangeable. Constants differ from normal variables in that you don’t use the $ symbol to declare or use them.

CONSTANT
<?php

class MyClass
{
const CONSTANT = ‘Kiran’;

function showConstant() {
echo self::CONSTANT . “\n”;

Read more

Autoloading Classes in PHP

Define an __autoload() function which is automatically called in case you are trying to use a class/interface which hasn’t been defined yet. By calling this function the scripting engine is given a last chance to load the class before PHP fails with an error.

__autoload
<?php

function __autoload($class_name) {
include

Read more

PHP Constructors and Destructors

Constructors : PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

__construct
<?php

class TestClass {
function __construct() {
print

Read more