why not?
just divide your every application into 2 parts - data preparation and data displaying.
Say, (aynı zamanda "iş mantığı" da denir), veri hazırlama parçası gibi görünebilir
<?
include 'config.php';
$data=db_query("SELECT * FROM data",3);
display($data,"users_list.tpl");
?>
Note the display() function. It's the function responsible for the data output. It can render both HTML and JSON, depends on the destination.
It code may look like
<?
if ($destination == 'desktop') echo json_encode($data);
else include $template;
?>
ve users_list.tpl gibi görünebilir
<a href="?id=0">Add item</a>
<? foreach ($data as $row): ?>
<li><a href="?id=<?=$row['id']?>"><?=$row['name']?></a>
<? endforeach ?>
Çok basit. Sadece iş mantığı kodu echo $row['name']; şeyleri önlemek.