PHP中的$this用法
<?php class test{ function abc(){ return '123'; } } header("Content-type: text/html; charset=utf-8"); $servername = 'localhost'; $username = '*****'; //用户名 $password = '****'; //密码 $dbname = "****"; //数据库 $pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); $redis = new Redis(); $time=strtotime('now'); $redis->connect('127.0.0.1', 6379); try{ $result = new test(); $ret = $result->abc(); var_dump($ret);//123 }catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?>
世界上最美的风景,是自己努力的模样