Home > Backend Development > PHP Tutorial > 【续】【PHP动态调用方法】带参数解决思路

【续】【PHP动态调用方法】带参数解决思路

WBOY
Release: 2016-06-13 10:21:38
Original
855 people have browsed it

【续】【PHP动态调用方法】带参数
其实我一直有个问题没用弄明白?
A.php
class Db{
  public static $db_table;
  pulbic static $db_connection;
  public function __construct(name){
  Db::db_table = name;
  }
}

甲用户
A.php?tbname=video  

乙用户
A.php?tbname=picture

---------------------
我看到好多自己封装的Db对象里面的connection竟然放在static里面。
这样并发访问,不会有问题吗?

------解决方案--------------------
数据库连接字只在当前程序中有效
保不保存,保存在哪里,都无所谓


------解决方案--------------------
这个是无所谓吧。。直接调用。
重复调还是实例化去吧。用$db -> xx
------解决方案--------------------
在php里,这两个用户是在不同的空间里, 它们各有一个DB类....而且不相干(就是静态属性也是独立的)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template