When I load it thorough my browser typing at the address bar: http://localhost/hello.php I get an “Hello world” declaration on my display.
Then I create an hello.HTML file with the following code:
when I load “hello.html” and click “php” anchor, what I get at my display is the php file’s source code.
I dont get the desired “Hello”.
Could anyone tell me why and what should I change to make the browser show “Hello” and not the source code?
Thanks
I suspect what you’re doing is opening the HTML file from your file system, perhaps by just browsing through file manager for it. What you need to do is the same as you did for the php file, in your browser address bar type in
http://localhost/hello.html
which will call the local WAMP/XAMP server to display the page and process the HTML. One way to check is when you open the html file, what does the browser address bar contain? If it starts with “file://” then it’s opened via the filesystem, if it starts with “http://” then it’s opened via the server.
It is not the same if the answer is different. One possibility is that the server might not be configured to process php files using PHP. Neither you nor deotpit specify what server software you are using for your local server. I am nearly certain that for IIS we must modify the configuration to specify use of PHP.
True, though in the case of the OP they had said that if they run the php code directly from the server, it works and produces the output they expected, hence my not considering the possibility that it might be a configuration thing.