PHP - Ds Set::construct() 函式



Ds\Set::__construct() 函式可以建立一個新例項。

語法

public Ds\Set::__construct([ mixed $...values ] )

Ds\Set::__construct() 函式可以使用可遍歷物件或陣列作為初始值來建立一個新例項。

示例 1

<?php 
   $set = new \Ds\Set(); 
   print_r($set); 
  
   $set = new \Ds\Set(["I", "N", "D", "I", "A"]);  
   print_r($set); 
?>

示例 2

<?php  
   $set = new \Ds\Set([1, 3, 5, 7, 9]);  
   var_dump($set); 
  
   $set = new \Ds\Set([1, 3, 5, 7, 9, 10]);  
   var_dump($set); 
?>
php_function_reference.htm
廣告