File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / lang / static_basic_001.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Static keyword - basic tests
    3: --FILE--
    4: <?php
    5: 
    6: echo "\nSame variable used as static and non static.\n";
    7: function staticNonStatic() {
    8: 	echo "---------\n";	
    9: 	$a=0;
   10: 	echo "$a\n";	
   11: 	static $a=10;
   12: 	echo "$a\n";
   13: 	$a++;	
   14: }
   15: staticNonStatic();
   16: staticNonStatic();
   17: staticNonStatic();
   18: 
   19: echo "\nLots of initialisations in the same statement.\n";
   20: function manyInits() {
   21: 	static $counter=0;
   22: 	echo "------------- Call $counter --------------\n";
   23: 	static $a, $b=10, $c=20, $d, $e=30;
   24: 	echo "Unitialised      : $a\n";
   25: 	echo "Initialised to 10: $b\n";
   26: 	echo "Initialised to 20: $c\n";
   27: 	echo "Unitialised      : $d\n";
   28: 	echo "Initialised to 30: $e\n";
   29: 	$a++;
   30: 	$b++;
   31: 	$c++;
   32: 	$d++;
   33: 	$e++;
   34: 	$counter++;
   35: }
   36: manyInits();
   37: manyInits();
   38: manyInits();
   39: 
   40: echo "\nUsing static keyword at global scope\n";
   41: for ($i=0; $i<3; $i++) {
   42:    static $s, $k=10;
   43:    echo "$s $k\n";
   44:    $s++;
   45:    $k++;
   46: }
   47: ?>
   48: --EXPECT--
   49: 
   50: Same variable used as static and non static.
   51: ---------
   52: 0
   53: 10
   54: ---------
   55: 0
   56: 11
   57: ---------
   58: 0
   59: 12
   60: 
   61: Lots of initialisations in the same statement.
   62: ------------- Call 0 --------------
   63: Unitialised      : 
   64: Initialised to 10: 10
   65: Initialised to 20: 20
   66: Unitialised      : 
   67: Initialised to 30: 30
   68: ------------- Call 1 --------------
   69: Unitialised      : 1
   70: Initialised to 10: 11
   71: Initialised to 20: 21
   72: Unitialised      : 1
   73: Initialised to 30: 31
   74: ------------- Call 2 --------------
   75: Unitialised      : 2
   76: Initialised to 10: 12
   77: Initialised to 20: 22
   78: Unitialised      : 2
   79: Initialised to 30: 32
   80: 
   81: Using static keyword at global scope
   82:  10
   83: 1 11
   84: 2 12

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>