📜  PHP | Ds\Deque __construct()函数

📅  最后修改于: 2022-05-13 01:56:54.796000             🧑  作者: Mango

PHP | Ds\Deque __construct()函数

Ds\Deque::__construct()函数是PHP中的一个内置函数,用于创建新实例。

句法:

Ds\Deque::__construct( $values )

参数:此函数接受单个参数$values ,它保存可遍历的对象或数组以使用初始值。

下面的程序说明了PHP中的Ds\Deque::__construct()函数:

方案一:


输出:
Elements of first deque:
object(Ds\Deque)#1 (0) {
}

Elements of second deque:
object(Ds\Deque)#2 (6) {
  [0]=>
  int(10)
  [1]=>
  int(20)
  [2]=>
  int(30)
  [3]=>
  int(40)
  [4]=>
  int(50)
  [5]=>
  int(60)
}

方案二:


输出:
Elements of first deque:
Ds\Deque Object
(
    [0] => geeks
    [1] => for
    [2] => geeks
)

Elements of second deque:
Ds\Deque Object
(
    [0] => G
    [1] => E
    [2] => E
    [3] => K
    [4] => S
    [5] => 1
    [6] => 2
    [7] => 3
)

参考: https://www. PHP.net/manual/en/ds-deque.construct。 PHP