PHP更改创建元素的样式[关闭]

I create ul and li elements and want to add a style but its not working.

<?php
      echo '<ul id="liste">';
        echo '<li>'.$_POST["vorname"].'</li>';
      echo '</ul>';
     $document->getElementsByTagName('ul')->item(0)->setAttribute("list-style-type","none");

     ?>

the error message:

Fatal error: Call to a member function getElementsByTagName() on null in C:\xampp\htdocs\manu\server.php on line 11

You have added together javascript and php script so try this.

<!DOCTYPE html>
<html>
<head>
<style>
.democlass {
    color: red;
}
</style>
</head>
<body>

<?php
  echo '<ul id="liste">';
    echo '<li>'.$_POST["vorname"].'</li>';
  echo '</ul>';
 ?>

<script>
    document.getElementsByTagName("ul")[0].setAttribute("style", "list-style-type: none;"); 

</script>

</body>
</html>

You are using the PHP DOM (http://php.net/manual/en/book.dom.php). This class can build an HTML document on the server side, but if you intend to update styles dynamically use Javascript.