18
I see that in python, has the Bottle for example that does the same thing of what I intend to do then...
I am new to web practices, student indeed and would like to know if I can use php and html in the same place,I wonder if this is a standard, not recommended, or whatever. Only Body because I intend to use Ajax and load the posts without refreshing the page.
Follow the example code:
<?php
function __autoload($class_name){
require_once $class_name . '.php';
}
?>
<body>
<?php
$noticia = new Noticia();
?>
<div id="posts">
<?php foreach ($noticia->findAll() as $value): ?>
<div style=" word-wrap: break-word; width: 400px; ">
<?php echo $value->mensagem; ?> <br><br><br><br>
</div>
<?php endforeach; ?>
</body>
Related question (possibly duplicate): http://answall.com/questions/7703/utilizo-php-dentro-de-um-html-ou-um-html-dentro-de-um-php
– gustavox
It has nothing to do with this question there. I want to know if the php developers currently develop in this way, or if there is another way. That question didn’t answer my question.
– Asura Khan
OK Asura, that’s why I said "related" and "possibly". I didn’t signal, nor did I vote to close, it was just a suggestion. I had already given +1 in your question, because I thought it was well done, in what weight to have thought that it could be duplicate.
– gustavox
In my opinion, 'No', many of the programmers I know also do not prefer this mixture. It is preferable to use an MVC Project, which separates the content, in which a
view
receive the variables to be used. After studying MVC, a good example is cakephp'– Guilherme Lautert
Not recommended. Look for some engine and template. If you are using some framework they already indicate a pattern.
– Fernando Souza