Are you running the script by double clicking the filename from Explorer??
If so DONT.
If you want a php script compiled and run, it has to be processed through Apache. The only way to do that is to enter the address in the browser's address bar.
So to run mytest.php that lives in \wamp\www\mytest.php you enter 'localhost/mytest.php' into the browser.
By the way while you are playing, make a subfolder in www so for example \wamp\www\chapter1 then put your testing code in there. Now you woudl use 'localhost/chapter1/mytest.php' to run the test code
---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>Read The Manuals Apache --
MySQL --
PHP --
phpMyAdminGet your Apache/MySQL/mariaDB/PHP ADDONs here from the
WAMPServer alternate Repo-X-X-X-
Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-