Preview with inline php code - Post...

User 2021487 Photo


Registered User
2 posts

Apologies for beginner's question: This very simple php code
<HTML><BODY>
<?PHP
if (3>2) echo("ABCD");
?>
</BODY></HTML>
produces
2) echo("ABCD"); ?>
That is, the '>' character in the if statement seems to end the Preview scan and subsequent skipping of php code. Everything following is treated is html text.
Seems like a fundamental question: is there any way to fix this? Or do I not understand?
Many thanks.

User 364143 Photo


Guest
5,410 posts

As far as I know, that won't work. You can save the PHP code in a .php file and include it in the html if your hosting server allows server side includes, or insert the .php file using a javascript call. It won't preview but will display on the page served by Apache.
CoffeeCup... Yeah, they are the best!
User 2021487 Photo


Registered User
2 posts

Thanks Tom,

The include works.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.