<?php
function test()
{
static $nm = ;
$nm = $nm * ;
print $nm."<br />";
}
// 第一次执行,$nm =
test();
// 第一次执行,$nm =
test();
// 第一次执行,$nm =
test();
?>
<?php
class nowamagic
{
public static $nm = ;
function nmMethod()
{
self::$nm += ;
echo self::$nm . '<br />';
}
}
$nmInstance = new nowamagic();
$nmInstance -> nmMethod();
$nmInstance = new nowamagic();
$nmInstance -> nmMethod();
?>
<?php
class NowaMagic
{
public static $nm = 'www.nowamagic.net';
public function nmMethod()
{
return self::$nm;
}
}
class Article extends NowaMagic
{
public function articleMethod()
{
return parent::$nm;
}
}
// 通过作用于限定操作符访问静态变量
print NowaMagic::$nm . "<br />";
// 调用类的方法
$nowamagic = new NowaMagic();
print $nowamagic->nmMethod() . "<br />";
print Article::$nm . "<br />";
$nmArticle = new Article();
print $nmArticle->nmMethod() . "<br />";
?>
<?php
function Demonstration()
{
return 'This is the result of demonstration()';
}
class MyStaticClass
{
//public static $MyStaticVar = Demonstration(); //!!! FAILS: syntax error
public static $MyStaticVar = null;
public static function MyStaticInit()
{
//this is the static constructor
//because in a function, everything is allowed, including initializing using other functions
self::$MyStaticVar = Demonstration();
}
} MyStaticClass::MyStaticInit(); //Call the static constructor
echo MyStaticClass::$MyStaticVar;
//This is the result of demonstration()
?>
<?php
function test()
{
static $var=;
$var+=;
echo $var.' ';
}
test();
test();
test();
?>
<?php
class TestC
{
public static $var=;
public $var=;
function t()
{
self::$var+=;
echo self::$var.' ';
echo $this->var.' ';
}
public static function t()
{
self::$var+=;
echo self::$var.' ';
}
}
$t=new TestC();
$t->t();
TestC::t();
?>
<?php
class TestC
{
public static $var=;
public $var=;
function t()
{
self::$var+=;
echo self::$var.' ';
echo $this->var.' ';
}
public static function t()
{
self::$var+=;
echo self::$var.' ';
}
}
$t=new TestC();
$t->t();
TestC::t();
?>
<?php
class Test
{
function t()
{
static::t();
}
public static function t()
{
echo self::'Test ';
}
}
class Test extends Test
{
static function t()
{
echo self::'Test ';
}
}
$t=new Test();
$t->t();
Test::t();
?>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有