The Ds\Deque::__construct() function is an inbuilt function in PHP which is used to create a new instance.
Syntax:
Ds\Deque::__construct( $values )
Parameters: This function accepts single parameter $values which holds the traversable object or array to use initial values.
Below programs illustrate the Ds\Deque::__construct() function in PHP:
Program 1:
<?php // Declare a deque $deq = new \Ds\Deque(); // Display the elements of deque echo("Elements of first deque:\n"); var_dump($deq); // Declare a deque $deq = new \Ds\Deque([10, 20, 30, 40, 50, 60]); // Display the elements of deque echo("\nElements of second deque:\n"); var_dump($deq); ?> |
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)
}
Program 2:
<?php // Declare a deque $deq = new \Ds\Deque(["geeks", "for", "geeks"]); // Display the elements of deque echo("Elements of first deque:\n"); print_r($deq); // Declare a deque $deq = new \Ds\Deque(['G', 'E', 'E', 'K', 'S', 1, 2, 3]); // Display the elements of deque echo("\nElements of second deque:\n"); print_r($deq); ?> |
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
)
Reference: https://www.php.net/manual/en/ds-deque.construct.php
Recommended Posts:
- What is the difference between a language construct and a “built-in” function in PHP ?
- JavaScript | Reflect.construct() Method
- JavaScript | handler.construct() Method
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- PHP | Imagick floodFillPaintImage() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
- PHP | stream_get_transports() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

