Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

language.oop5.static function syntax tag tutorial 2013





Alert! Connect with 10,000 Chating Online. Join Now

Php language.oop5.static () function

Write your php code

 
<?php ?>

Php Result


Your code below



Static Keyword

Declaring class members or methods as static, makes them callable from outside the object context. A member or method declared with static can not be accessed with a variable that is an instance of the object and cannot be re-defined in an extending class.

The static declaration must be after the visibility declaration. For compatibility with PHP 4, if no visibility declaration is used, then the member or method will be treated as if it was declared as public static.

Because static methods are callable without an instance of the object created, the pseudo variable $this is not available inside the method declared as static.

In fact static method calls are resolved at compile time. When using an explicit class name the method is already identified completley and no inheritance rules apply. If the call is done by self then self is translated to the current class, that is the class the code belongs to. Here also no inheritance rules apply.

Static properties cannot be accessed through the object using the arrow operator ->.

Example 19-13. Static member example

<?php
class Foo
{
    
public static $my_static = 'foo';

    
public function staticValue() {
        return
self::$my_static;
    }
}

class
Bar extends Foo
{
    
public function fooStatic() {
        return
parent::$my_static;
    }
}


print
Foo::$my_static . "\n";

$foo = new Foo();
print
$foo->staticValue() . "\n";
print
$foo->my_static . "\n";      // Undefined "Property" my_static

// $foo::my_static is not possible

print Bar::$my_static . "\n";
$bar = new Bar();
print
$bar->fooStatic() . "\n";
?>

Example 19-14. Static method example

<?php
class Foo {
    
public static function aStaticMethod() {
        
// ...
    
}
}

Foo::aStaticMethod();
?>

Php language.oop5.static Function syntax tag

language.oop5.static php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php language.oop5.static syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online