No PHP
Posted by: abrooks (---.static.optonline.net)
Date: October 27, 2014 07:02PM

I'm having trouble with PHP output. I'm not sure if I've installed or configured WampServer correctly

I copied the following from [www.w3schools.com]

<!DOCTYPE html>
<html>
<body>

<?php
$x=5;
$y=6;
$z=$x+$y;
echo $z;
?>

</body>
</html>

to my Index.html.

I get no output - a blank web page. The "Run Example" button at w3schools shows "11" as the output.

I modified the code:

<!DOCTYPE html>
<html>
<body>

<?php
$x=5;
$y=6;
$z=$x+$y;
echo '<p>'.$z.'</p>';
?>

</body>
</html>

And got this as the output

'.$z.'
'; ?>


Can anyone point me in the right direction to fix this?

Options: ReplyQuote
Re: No PHP
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: October 27, 2014 07:08PM

Call the file index.php


Unless the extension is .php Apache will not pass the script to the PHP interpreter.

---------------------------------------------------------------------------------------------
(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 -- phpMyAdmin
Get 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-

Options: ReplyQuote
Re: No PHP
Posted by: abrooks (---.static.optonline.net)
Date: October 27, 2014 07:28PM

So then

<?php ... ?>

Tag in an HTML file is not treated by Apache? Well, at least as far as the output I did get, Apache is confused by it.

I'd like to write HTML that is augmented with PHP - not solely PHP. According to the tutorials at w3schools this should be a common thing. Is there no way to have Apache cooperate other that making everything PHP. This seems odd.

Options: ReplyQuote
Re: No PHP
Posted by: abrooks (---.static.optonline.net)
Date: October 27, 2014 07:46PM

Oh, I think I get it and its counter intuitive - me at least. The file must just have a PHP extension. The contents will remain HTML but because in has PHP tags as well Apache needs that extension as a clue to hand off when needed.

Sorry, this was not a WampServer configuration issue. But

thank you.

Options: ReplyQuote


Sorry, only registered users may post in this forum.