Ds \ Vector::__construct()函數是PHP中的一個內置函數,用於創建新實例。
用法:
public Ds\Vector::__construct( $values )
參數:此函數接受單個參數$values,該參數保存可遍曆的對象或數組以使用初始值。
以下示例程序旨在說明PHP中的Ds \ Vector::__construct()函數:
程序1:
<?php
// Declare a new Vector
$vect = new \Ds\Vector();
print_r($vect);
// Declare a new set
$vect = new \Ds\Vector(['G', 'E', 'K', 'S']);
print_r($vect);
?>
輸出:
Ds\Vector Object ( ) Ds\Vector Object ( [0] => G [1] => E [2] => K [3] => S )
程序2:
<?php
// Declare a new vector
$vect = new \Ds\Vector([2, 3, 6, 7, 8]);
var_dump($vect);
// Declare a new vector
$vect = new \Ds\Vector([2, 3, 5, 8, 9, 10]);
var_dump($vect);
?>
輸出:
object(Ds\Vector)#1 (5) { [0]=> int(2) [1]=> int(3) [2]=> int(6) [3]=> int(7) [4]=> int(8) } object(Ds\Vector)#2 (6) { [0]=> int(2) [1]=> int(3) [2]=> int(5) [3]=> int(8) [4]=> int(9) [5]=> int(10) }
參考: https://www.php.net/manual/en/ds-vector.construct.php
相關用法
- p5.js pan()用法及代碼示例
- p5.js day()用法及代碼示例
- PHP key()用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- PHP pos()用法及代碼示例
- p5.js min()用法及代碼示例
- PHP max( )用法及代碼示例
- p5.js max()用法及代碼示例
- PHP sin( )用法及代碼示例
- d3.js d3.mean()用法及代碼示例
- d3.js d3.sum()用法及代碼示例
注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | Ds\Vector __construct() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。