我怎么能用PHP写一个html代码(模板)到一个html文件?

时间:2015-05-29 05:11:03

标签: php html fopen fwrite fclose

如何使用php $rootScope.$on('listen', function() { $scope.displayString(); }); $scope.displayString = function() { console.log('test'); // This display 7 times because I visit the controller 7 times } 将html代码(不可执行)写入文件。例如,我想放置包含filesystemsDOCTYPEHEADERBODY BLOCK等的html页面模板。

2 个答案:

答案 0 :(得分:0)

  List<Combox> comboxs = new List<Combox>;
    comboxs.Add(cmb1);
    comboxs.Add(cmb2);
    comboxs.Add(cmb3);
    comboxs.Add(cmb4);
  foreach(var combox in comboxs){
    Console.WriteLine(combox.Name + "has" + combox.SelectedItem + "value");
  }

Your first PHP-enabled page

Read more

答案 1 :(得分:0)

因为我问你了

将文件index.php保存为index.html

你可以使用

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
</body>
</html>

什么时候你需要写一个PHP(在体内)

使用

<?php
//php code goes here
?>

例如

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
//php code goes here
?>
</body>
</html>
文件扩展名为php时,

.php将有效。如果文件扩展名为.html,则浏览器无法识别您的PHP code,并且会在浏览器上显示完整代码