AMHO, use this
https://wiki.freepascal.org/fpWeb_Tutorial or use this
https://www.php.net/manual/fr/index.php.
Mixing the two isn't recommended, if its possible: be aware that mixing the 2 languages means that the CGI-Pascal-fpWeb named session - said PASCAL_SESSID, or whatever you want - knows how to retrieve the Php named session - said PHP_SESSID, or whatever you want - in order to be assigned with its\some web session variables (using embedded COOKIE or URL's GET or URL's POST shuttle), or vice versa. Absolutely possible. But this complicates things.
nb1: Php was created as a *.htm template handling laguage. For information, fpWeb has a *.htm template engine named fpTemplates.
nb2: CGI-Pascal-fpWeb is just a console program.