コード例 #1
0
function main()
{
    echo "Entering main\n";
    // SetM with array base on the stack
    makeArr()['dumper'] = new stdclass();
    makeArrRef()['dumper'] = 24;
    makeArrRef()[234] = 234;
    // More complex SetM with array base on the stack, then with a ref
    makeArr()['dumper']->prop = null;
    makeArrRef()['dumper']->propp = null;
    makeArrRef()['dumper']->proppp = null;
    // Clear out the reference to destruct the array
    $ref =& makeArrRef();
    var_dump($ref);
    $ref = null;
    // SetM and CGetM with an object base on the stack
    makeObj()->prop = 'foo';
    var_dump(makeObj()->prop);
    makeObjRef()->prop = 'bar';
    var_dump(makeObjRef()->prop[2]);
    // UnsetM
    unset(makeArr()['dumper']);
    echo "Done with main\n";
}
コード例 #2
0
ファイル: lesson02_task02.php プロジェクト: andyskyba/sky
<?php

/**
 * Created by PhpStorm.
 * User: user
 * Date: 05.01.16
 * Time: 11:55
 */
$capacityArr = 10;
$Array = [];
//call function to make array and display it
makeArr($Array, $capacityArr);
var_dump($Array);
//function receive array via link and fulfill it with data according to capacity
function makeArr(&$array, $capacity)
{
    for ($i = 0; $i < $capacity; $i++) {
        $array[$i] = pow($i, 2);
    }
}