I use an official example of working with a linear stack \ ds \ stack (): https://www.php.net/manual/ru/class.ds-stack.php
$ stack = new \ ds \ stack ();
$ stack- & gt; push ("a");
$ stack- & gt; push ("b");
$ stack- & gt; push ("c");
VAR_DUMP ($ stack- & gt; pop ());
VAR_DUMP ($ stack- & gt; pop ());
VAR_DUMP ($ stack- & gt; pop ());
Gives an error: Fatal Error: Uncaught Error: Class ‘Ds \ Stack’ Not Found In C: \ Ospanel \ domains \ lab5.cd \ index.php: 2 stack trace: # 0 {Main} Thrown in C: \ OSPANEL \ Domains \ Lab5.cd \ index.php on line 2
$ q = new splstack ();
works
just start studying stacks I do not understand why it does not work = (how to fix it and what is the problem
Answer 1
If you want to use \ ds \ stack ()
You need to install the extension ext-ds
and PECL DS module. Although I advise you to use Splstack ()
, if you do not need to use other structures from this module. Reference to Ext-DS repository You can also read the installation instructions