PHP | Ds\Stack capacity() Function
The Ds\Stack::capacity() function is an inbuilt function in PHP which is used to return the current capacity of the stack.
Syntax:
int Ds\Stack::capacity( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the current capacity of the stack.
Below programs illustrate the Ds\Stack::capacity() function in PHP:
Program 1:
<?php
$stack = new \Ds\Stack();
var_dump( $stack ->capacity());
?>
|
Program 2:
<?php
$stack = new \Ds\Stack();
echo ( "Current Capacity is: " );
var_dump( $stack ->capacity());
echo ( "Current Capacity is: " );
$stack ->allocate(5);
var_dump( $stack ->capacity());
echo ( "Current Capacity is: " );
$stack ->allocate(120);
var_dump( $stack ->capacity());
?>
|
Output:
Current Capacity is: int(8)
Current Capacity is: int(8)
Current Capacity is: int(120)
Reference: https://www.php.net/manual/en/ds-stack.capacity.php
Last Updated :
30 Jul, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...