Reputation: 7086
My code is like this :
<?php
for($i=0;$i<5; $i++) {
?>
<div class="img-container">
test
</div>
<?php
}
?>
My code works in localhost, but in jsfiddle, it does not work.
I try in jsfiddle like this : https://jsfiddle.net/oscar11/5fjgsuds/
How can I solve this problem?
Upvotes: 0
Views: 232
Reputation: 28554
You need to use a php environment to parse the php code. You can run your php code in some php sanbox on line like the eval.in
check you code on eval.in
Upvotes: 1
Reputation: 12085
As per comment of OP @JYoThI, How can I run loop html in jsfiddle?. you can do this using client side script like javascript or jquery like this
$(document).ready(function()
{
html='';
for(i=0;i<5;i++)
{
html+= '<div class="img-container">test</div>';
}
$('body').html( html);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
</body>
Upvotes: 0
Reputation: 523
HTML code is not equal to php code. In php, the code is executed and the result is returned. Basically you specify the resultant code is html to the browsers(currently most browsers expect html).
jsfiddle doesnot support php, .i.e, it doesnot execute it, so you should have a look at http://phpfiddle.org/, this one supports php. This is the reason why your code is not working on jsfiddle.
For anymore clarifications please comment.
Upvotes: 1