I need to include html code inside a php function,after to use the function in another html code. The HTML code should be in another file, i want to call that code in specified row in another file.
HTML code
<span>
<?php
$register_date = new Moment\Moment($u->get("date"), date_default_timezone_get());
$register_date->setTimezone($AuthUser->get("preferences.timezone"));
$format = $AuthUser->get("preferences.dateformat");
if (!$format) {
$format = "Y-m-d";
}
?>
<?= __("Register date: %s", $register_date->format($format)) ?>
</span>
The function
function thefunction (){
//the html code here
}
The code i want to include the function
<?php if ($u->get("expire_date") < "2050"): ?>
<div class="meta">
<?php ?>
function thefunction ()//The function
?>
</div>
<?php endif ?>
Normal code without the function
<?php if ($u->get("expire_date") < "2050"): ?>
<div class="meta">
<span>
<?php
$register_date = new Moment\Moment($u->get("date"), date_default_timezone_get());
$register_date->setTimezone($AuthUser->get("preferences.timezone"));
$format = $AuthUser->get("preferences.dateformat");
if (!$format) {
$format = "Y-m-d";
}
?>
<?= __("Register date: %s", $register_date->format($format)) ?>
</span>
</div>
<?php endif ?>