-1
我来自一个C#
背景,你可以做以下从任何方法的类静态变量在PHP类
public class Test
{
private static servername = "servername";
private static dbname = "testdb";
private static username = "username";
private static password = "password";
//Any method here could read the values of the static
//variables that are declared above
}
内重复使用的变量有没有办法做同样的php
如果多正在使用相同的用户凭据对相同的数据库进行调用,以便信息不会多次输入?
本质上是某种数据库调用的可重用语法,而不是每次需要查询并返回结果时重新输入相同的8-10行。
编辑.......
至于可重用的代码去,我终于找到了这之后更google搜索
http://code.tutsplus.com/tutorials/simple-php-class-based-querying--net-11863
是的,它是只使用一个搜索离你而去[文档中](https://secure.php.net/manual/ language.oop5.static.php)... – Blackhole
将'$'放在静态成员名称的前面。 –