EDWCode
EDWCode

Reputation: 27

Replacing HTML with PHP

As I'm working on big code, I'm wondering is there any possibilities replacing HTML with PHP code more easily so that for example <?php $HelloWorld ?> would become something like --HelloWorld-- in the document? Or for example the loop would go from:

<?php 
for ($x = 0; $x <= 10; $x++) {
    echo "The number is: $x <br>";
} 
?>

To simplified string like

-(10)-{The number is: $x <br>}-

Upvotes: 0

Views: 87

Answers (1)

Edvard &#197;kerberg
Edvard &#197;kerberg

Reputation: 2191

What you are looking for is a templating engine.

Many if not all of the major php frameworks have a templating engine that gives you the possibility to use templates like this.

Laravel for example uses a templating engine called blade which enables you to write in blade syntax.

The number is {$x}

Or

@foreach ($users as $user)
 {$user->name} <br>
@endforeach

Or

@if(true)
 Do this
@else
 Else do that
@endif

Hope this helps

Upvotes: 3

Related Questions