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();
}






?>

 

posted @ 2021-01-06 10:19  大熊童鞋  阅读(397)  评论(0编辑  收藏  举报