<!DOCTYPE html> <html> <body> <?php $x=5; $y=6; $z=$x+$y; ?> <p><?php echo $z; ?></p> <p>Hello</p> </body> </html>
Simple PHP code in html not working
Page 1 of 15 Replies - 328 Views - Last Post: 11 March 2013 - 11:15 PM
#1
Simple PHP code in html not working
Posted 08 March 2013 - 11:46 AM
This seems like really simple php code, but it doesn't seem to work
Replies To: Simple PHP code in html not working
#2
Re: Simple PHP code in html not working
Posted 08 March 2013 - 11:54 AM
What makes you think it doesn't work? Do you receive error messages?
My guess would be that you are not loading the page via a web-server.
My guess would be that you are not loading the page via a web-server.
#3
Re: Simple PHP code in html not working
Posted 08 March 2013 - 11:59 AM
I'm supposed to get the value of z back, instead it just prints out Hello
#4
Re: Simple PHP code in html not working
Posted 08 March 2013 - 02:13 PM
andrewsw, on 08 March 2013 - 12:54 PM, said:
What makes you think it doesn't work? Do you receive error messages?
My guess would be that you are not loading the page via a web-server.
My guess would be that you are not loading the page via a web-server.
That would be my guess to from what he's saying. And make sure your page that you save ends in .php as well as be on a web server with PHP enabled.
#5
Re: Simple PHP code in html not working
Posted 11 March 2013 - 09:38 PM
try
echo "$z";
echo "$z";
#6
Re: Simple PHP code in html not working
Posted 11 March 2013 - 11:15 PM
View page source should tell you whats going on, however without php installed the page should just display the code as well as hello.
On a second thought, if for some reason your php executable is all screwy for whatever reason, you could get some odd stuff back, possibly check your web server error logs also. Like you say, too simple to not work really.
On a second thought, if for some reason your php executable is all screwy for whatever reason, you could get some odd stuff back, possibly check your web server error logs also. Like you say, too simple to not work really.
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote




|