Home How to get parameters in class function with php class
Reply: 0

How to get parameters in class function with php class

user953
1#
user953 Published in July 18, 2018, 12:40 am

In my project, I had defined a Datasource class in php.

I want to call function with class, so I had define static getRedis function in Datasource class.

Here is Datasource.php code:

<?php

 namespace common;

 class Datasource {

 public $config_name;  

 public $server_region;  


public function __construct() {}

public static function getRedis($config_name = NULL, $server_region = 'default') {
    $this->config_name=$config_name;
    $this->server_region=$server_region
    return $this->config_name;
}
}

Now I want to call getRedis function and display instance1 in my html page;

Here is html code:

<?php 
include "o1ws1v/class/common/Datasource.php";

$redis_obj = common\Datasource::getRedis('instance1');
echo $redis_obj;
?>

But it words fail. I can not get $redis_obj. it shows nothing.

Who can help me?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.314466 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO