Why does some PHP code look like HTML comment

I just started learning PHP and install webmatrix to get started. My first test page displays a piece of PHP code as HTML comments. I need help figuring out what happened. One include statement works fine and the other one is in the same file as shown below. None of the PHP code with HTML rendering is rendered. The file contains HTML and PHP code and is named with a .PHP extension. I have PHP enabled in my site settings.

For example, this line:

<?
include "phpinfo.php";    
?>

      

becomes:

<!--? include "phpinfo.php"; ?-->

      

05/11: Thanks for the help. I got his job and learned a few things.

+3


source to share


1 answer


Ideally, you should use php <?php

to open and ?>

close calculations. You can use short tags <?=

and ?>

if you just want to print the value.

Anyway, it seems to me that php is not showing up by your webserver. When a tag is <?

accepted by the browser, the browser treats it as something that shouldn't be passed on to the end user (which it really shouldn't - it should be evaluated by your server before being sent to the client).

try the following line in your php file:



<?php phpinfo() ?>

If that doesn't work, you need to check if php is actually working on your server.

If this works, then as Darren commented below, it is likely that you do not have short tags set in your file php.ini

- see SO answer here

+6


source







All Articles