Home php PHP error: ds stack () Class not found

PHP error: \ ds \ stack () Class not found

Author

Date

Category

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

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions