Can I use two different php versions to generate a web page? [closed]

I use the CMS dokuwiki to display contents, some of these contents being created by php scripts written in php 5.4. At the moment, I’m using an old version of dokuwiki also running with php 5.4. But to use some new functionalities and security fixes of dokuwiki, I must update it to a newer version running with php 7 or 8. It is possible to have dokuwiki with php 7 or 8 displaying pages created with php 5.4. Rewriting these 5.4 scripts is not an option.
The web server is apache with cgi. It already accommodates several php versions but for different urls.