PHP | Ds\Stack push() Function Last Updated : 20 Jan, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Stack::push() function of PHP is used to add elements at the end of the stack. That it is used to push elements on to a stack. The elements being pushed can be of mixed data types. Syntax: void public Ds\Stack::push ($values) Parameter: This function accepts a single parameter $values which is used to push onto the stack. Return Value: This function does not return any value. Below programs illustrate the Ds\Stack::push() function: Program 1: PHP <?php // PHP program to illustrate the // Ds\stack::push() function // Create a Stack instance $stack = new \Ds\Stack(); // Pushing elements to Stack $stack->push("Welcome"); $stack->push("to"); $stack->push("GfG"); // Print the stack print_r($stack); ?> Output: Ds\Stack Object ( [0] => GfG [1] => to [2] => Welcome ) Program 2: PHP <?php // PHP program to illustrate the // Ds\stack::push() function // Create a Stack instance $stack = new \Ds\Stack(); // Pushing Mixed value elements to Stack $stack->push("Welcome"); $stack->push("to"); $stack->push("GfG"); $stack->push(10); $stack->push(5.5); // Print the stack print_r($stack); ?> Output: Ds\Stack Object ( [0] => 5.5 [1] => 10 [2] => GfG [3] => to [4] => Welcome ) Reference: https://www.php.net/manual/en/ds-stack.push.php Comment More infoAdvertise with us Next Article PHP | DsDeque push() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_stack Similar Reads PHP | DsStack push() Function The Ds\Stack::push() function of PHP is used to add elements at the end of the stack. That it is used to push elements on to a stack. The elements being pushed can be of mixed data types. Syntax: void public Ds\Stack::push ($values) Parameter: This function accepts a single parameter $values which i 1 min read PHP | DsDeque push() Function The Ds\Deque::push() function is an inbuilt function in PHP which is used to add the elements to the Deque by appending an element at the end of the Deque. Syntax: public Ds\Deque::push( $values ) : void Parameters: This function accepts single parameter $values which holds the elements to be added 2 min read PHP DsQueue push() Function The Ds\Queue::push() Function in PHP is used to push or insert values in a PriorityQueue instance. This function can also insert a list of values directly to the Queue. Syntax: void public Ds\Queue::push($value1, $value2, .... $valueN) Parameters: This function accepts a list of values separated by 1 min read PHP | DsVector push() Function The Ds\Vector::push() function is an inbuilt function in PHP that is used to add elements to the end of the vector. Syntax: void public Ds\Vector::push( $values ) Parameters: This function accepts a single parameter $values which contains one or more than one element to be added to the vector. Retur 2 min read PHP | DsSequence push() Function The Ds\Sequence::push() function is an inbuilt function in PHP which adds values to the end of the sequence. Syntax: void abstract public Ds\Sequence::push( $values ) Parameters: This function accepts single parameter $values which contains one or more values. It hold the value to be added in the se 2 min read PHP | DsDeque unshift() Function The Ds\Deque::unshift() function is an inbuilt function in PHP which is used to add the value in front of the deque. Syntax: void Ds\Deque::unshift( $values ) Parameters: This function accepts single parameter $values which holds the values to add in the front of the deque. Return Value: This functi 2 min read PHP | Ds\Stack push() Function min read Like