Host $ host; $ this-& gt; root $ root; $ this-& gt; password $ password;} functionconnect () {@ mysql_connect ($ this-& gt; host, $ this-& gt; root, $ this-& gt; password); mysql_select_db ($ this-& gt; database); mysql_query (& quot; setnamesutf8 & quot ;);} functionc php
Class mysql {
Public $ host;
Public $ root;
Public $ password;
Public $ database;
function __construct ($host,$root,$password){ $this->host =$host; $this->root =$root; $this->password =$password ; } function connect (){ @mysql_connect ($this->host,$this->root,$this->password); mysql_select_db ($this->database); mysql_query ("set names utf8"); } function close(){ mysql_close(); } function select(){ $result=mysql_query("select * from users"); print_r ($result); }} $link=new mysql("localhost","root","","stu_system");$link->connect();$link->select();$link->close();
?>
Starting from a few days ago, I wrote the object-oriented document and finally felt that I was still writing process-oriented documents. what happened ~~~
Finally, the webpage does not display information.
I am self-taught and have limited abilities ~~ Ask for advice ~~