PHP Ds / Stack Capacity () Function

PHP

Syntax:
int DsStack::capacity (void)
Parameters:this function takes no parameters.Return value:this function returns the current capacity of the stack.The following programs illustrate the Ds / Stack::acity() function in PHP:Program 1:  
// Declare a new stack $stack = new DsStack();  
// Use the Capacity() function to check
// current capacity var_dump ( $stack -> capacity());  
?>
Exit:
int (8 )
Program 2:  
// Declare a new stack $stack = new DsStack(); echo ( " Current Capacity is: " );  
// Using the Capacity() function // check the current capacity var_dump ( $stack -> capacity()); echo ( " Current Capacity is: " );  
// Use the allocate() function for
// share power $stack -> allocate (5);  
// Show selected vector
// capacity var_dump ( $stack -> capacity()); echo ( " Current Capacity is: " );  
// Use the allocate() function for
// share power $stack -> allocate (120);  
// Show selected vector
// capacity var_dump ( $stack -> capacity());  
?>
Exit:
Current Capacity is : int (8) Current Capacity is: int (8) Current Capacity is: int (120)
Link:https://www.php.net/manual/en/ds-stack.capacity.php



Get Solution for free from DataCamp guru