Tamam ne yapmak istediğiniz bir moda mümkündür.
Sadece bir php değişkene HTML bloğunu atamak ya da bir işlevi ile bunu yapamazsınız. Ancak istediğiniz sonucu elde etmek için bir kaç yolu var.
- Bir çiftleşmiş motoru kullanımı (ben ise zaten değer olarak bunu öneririm) araştırmak. I smarty kullanmak, ama diğerleri var
- İkinci bir çıkış tamponu kullanmaktır.
One of the problems you have is that any HTML you have in your page is immediately sent to the client which means it cant be used as a variable in php. However if you use the functions
ob_start and ob_end_fush you can achive what you want.
örneğin
<?php
somesetupcode();
ob_start(); ?>
<html>
<body>
html text
</body>
</html>
<?php
//This will assign everything that has been output since call to ob_start to your variable.
$myHTML = ob_get_contents() ;
ob_end_flush();
?>
Bu php docs output buffers kadar okuyabilirsiniz yardımcı olur umarım.