学习php需要了解的点1

来源:互联网 发布:js如何修改元素属性值 编辑:程序博客网 时间:2024/05/18 02:36

因为之前一直在用C#,最近搞了搞微信公众平台和微博的开发,用到了php。

其中很多不同之处,本人通过查询得知一些技术点。再此留下,供参考。

== PHP ==

$result = var_export($content, true) PHP 输出数组内容的方法,第二个参数是true,则该函数支持有返回值。


== PHP ==

面向对象编程:类中调用本类的方法,用$this->function(); 前面的$this坚决不能省略。


== PHP ==

面向对象编程:类中使用本类的成员,用$this->成员名字; 前面的$this坚决不能省略,成员名字不加$符号。


== PHP ==

类的构造函数

public function __construct()

注意construct前面是两个_。


== PHP 使用PostGreSql数据库时 ==

Note: connection 是 pg_query() 中的可选参数。如果没有指定 connection,则使用默认连接。默认连接是 pg_connect() 或 pg_pconnect() 所打开的最后一个连接。 尽管 connection 参数可以省略,但不推荐这样做。因为这样可能会导致很难发现脚本中的错误。



== PHP 生成GUID ==

  private function create_guid(){    $charid = strtoupper(md5(uniqid(mt_rand(), true)));    $hyphen = chr(45);// "-"    $uuid = chr(123)// "{"    .substr($charid, 0, 8).$hyphen    .substr($charid, 8, 4).$hyphen    .substr($charid,12, 4).$hyphen    .substr($charid,16, 4).$hyphen    .substr($charid,20,12)    .chr(125);// "}"    return $uuid;}    private function create_guid_12Bit(){    $charid = strtoupper(md5(uniqid(mt_rand(), true)));    $uuid = chr(123)// "{"    .substr($charid,20,12)    .chr(125);// "}"    return $uuid;}


0 0