Reputation: 402
Can i do something like php macro in html page, for example:
<html>
<head>
</head>
<body>
<?php if(Block1()):?>
<div>
some html code
</div>
<?php endif;?>
</body>
</html>
Can i change this code:
<?php if(Block1()):?>
<div>
some html code
</div>
<?php endif;?>
with some macro like,
#startBlock1
<div>
some html code
</div>
#endBlock1
Upvotes: 0
Views: 322
Reputation: 4062
You could read the html
file into a string
see: php.net file_get_contents()
and then replace some patterns or keywords with some other text see: php.net str_replace(), preg_replace()
if you want to run a function you could seek for the presence of a string / keyword see php.net strpos(), preg_match()
Upvotes: 1
Reputation: 701
If you mean macro, which will be executed after page will be loaded in browser - No, you can't php scripts are executed on server side.
Upvotes: 2