# storeengine/2.2.0/includes/classes/eval-math/eval-math-stack.php

StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates &amp; More, version 2.2.0. 65 lines.

- Page: https://pluginprobe.com/plugins/storeengine/2.2.0/code/includes/classes/eval-math/eval-math-stack.php
- Raw: https://pluginprobe.com/plugins/storeengine/2.2.0/raw/includes/classes/eval-math/eval-math-stack.php
- Modified: 2026-07-30T16:04:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/storeengine/2.2.0/code/includes/classes/eval-math/eval-math-stack.php#L10-L20`.

```php
<?php

namespace StoreEngine\Classes\EvalMath;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class EvalMathStack
 *
 * Expression-evaluator stack.
 */
class EvalMathStack {

	/**
	 * Stack array.
	 *
	 * @var array
	 */
	public $stack = array();

	/**
	 * Stack counter.
	 *
	 * @var integer
	 */
	public $count = 0;

	/**
	 * Push value into stack.
	 *
	 * @param  mixed $val
	 */
	public function push( $val ) {
		$this->stack[ $this->count ] = $val;
		$this->count++;
	}

	/**
	 * Pop value from stack.
	 *
	 * @return mixed
	 */
	public function pop() {
		if ( $this->count > 0 ) {
			$this->count--;
			return $this->stack[ $this->count ];
		}
		return null;
	}

	/**
	 * Get last value from stack.
	 *
	 * @param  int $n
	 *
	 * @return mixed
	 */
	public function last( $n = 1 ) {
		$key = $this->count - $n;
		return array_key_exists( $key, $this->stack ) ? $this->stack[ $key ] : null;
	}
}

```
