PHP Within HTML Not Working Using Flask
I have just recently started playing around with Flask and have no previous html/php experience, so please forgive me if this is naive! I'm trying to use some php within an html f
Solution 1:
You would not use PHP in Flask. If you want some scripting logic in your template, use something like this:
<html>
<head></head>
<body>
<ul>
{% for i in range(1,6) %}
<li>Menu Item {{ i }}</li>
{% endfor %}
</ul>
</body>
</html>
Solution 2:
Answer to question by Matt Healy is right.
But looking at your code I seem problem it should be like this
<ul>
<?php
for($i=1;$i<=5;$i++){
echo "<li>Menu Item ".$i."</li>";
}
?>
</ul>
And make sure you have .php
as the file extension. Because Php will not run in HTML file.
Solution 3:
The PHP interpreter does not work the way you want to use it. You are calling the HTML (template) file from within a flask app, thus not using the PHP interpreter. You best stick to PHP with supportet templating eg. smarty, or go for Pythonic. Trying mixing the two is a bad idea.
Post a Comment for "PHP Within HTML Not Working Using Flask"