Mar092012
php __construct函数和构造函数分析
php4以前的版本中,类的构造函数即是类的同名函数,而到了php5类的构造函数多了一个__construct魔法函数,那当这两个同时存在时,构造实例时调用的到底是哪个函数呢?
1、两个函数都存在的情况下
Php代码
<?php
class A{
var $str = "construct";
function __construct(){
$this->str = "construct";
}
function A(){
$this->str = "A";
}
}
$a = new A()...阅读全文
抢沙发
Mar052012
php explode与split的区别
今天在使用split时遇到一些问题。还是对函数理解不深刻,特写出来做个记号。
首先来看下两个方法的定义:
函数原型:array split (string $pattern, string $string [, int $limit])
函数原型:array explode ( string $separator, string $string [, int $limit])
初看没有啥差别,貌似功能都一样。我就犯了这个错误。 请注意两个函数的第一个参数string $pattern和string sep...阅读全文
Mar022012
php exec用法详解
exec函数解析
exec语法: string exec(string command, string [array], int [return_var]);
exec返回值: 字符串
Exec参数说明
Command – 需要执行的命令
Array – 是输出值
return_var –是返回值0或1,如果返回0则执行成功,返回1则执行失败。
exec不成功,调试方案
一个技巧就是使用管道命令, 使用 2>&1, 命令就会输出shell执行时的错误到$output变量, 输出该变量即可分析...阅读全文
Mar012012
php下eclipse 用空格替换 tab键
本人用eclipse进行PHP项目开发,根据公司开发规范,要用4个空格替换掉tab键,详细的配置如下:
1. windows=》preferences=》general=》editors=》text editors 勾选 “insert spaces for tabs”
2. windows=》preferences=》phpeclipse=》php=》typing 勾选 “insert spaces for tabs(……)”
至此,配置完毕。
但是因为版本的不同,有些会出现这样的问题:if{ ...阅读全文
Feb292012
Feb252012
Feb252012