哪一天 哪一天 我有吃有穿有住有钱 不再流浪 流浪

在windows下php.ini中打开extension = curl.dll 没有效果.

解决方案
把PHP的安装目录加入到系统的环境变量
或者把这libeay32.dll, ssleay32.dll,php5ts.dll拷贝到system32目录下
推荐第一种
前提是php.ini中要把extension=php_curl.dll 前面的注释去掉.

强制执行parent::__construct(), self才是当前的对象

<?php
class A
{
    function __construct()
    {
      echo ‘construct’;
    }

    function test()
    {
       echo ‘test’;
    }
}

class B extends A
{
function __construct()
{
       // 正确的写法
       parent::__construct();
       self::test();

       //错误的写法
       //$b = parent::__construct();
       //$b->test();
   }
}

$b = new B();
?>

今天在这上面花了不少时间,还是对oop的理解不是很深刻才会造成这个错误.
这是我用zendframework写的认证

<?php
/*
* Created on 2008-5-17 01:23:00
*
* Auth.php
*
* @author: sanp
* @blog: http://hi.baidu.com/tecent
*/
class Sanp_Auth extends Zend_Auth_Adapter_DbTable
{
    public function __construct($userName, $userPassword)
    {  
        $dbAdapter = Zend_Db_Table::getDefaultAdapter();
        parent::__construct($dbAdapter, ‘users’, ‘user_name’, ‘user_password’);
       
        // set credentials value
        self::setIdentity($userName);
        self::setCredential($userPassword);
       
        // run credential query and save the result
        $result = self::authenticate();
    }
}

每次login的时候调用下这个就可以了.
$auth = new Sanp_Auth($userName, $userPassword);

2008-05-18程序设计

没有评论
8 views

Determine class type with these 10 PHP variable testing functions

Takeaway: This document outlines the more useful functions available in a toolkit of PHP functions designed specifically to test variables and find out if they belong to a particular character class.

Unlike many of its counterparts, PHP is not a strictly typed language. Essentially, this means that a developer doesn’t need to explicitly set the type (number, string, Boolean) of a variable before using it. Instead, the PHP interpreter automatically detects variable type based on the information stored within a variable.

While this makes programming in PHP very easy, it does have an important drawback: when you do actually need to test a variable’s type, a loosely typed language can be somewhat confusing to deal with. Luckily, the developers of PHP knew this and therefore included a toolkit of functions designed specifically to test variables and find out if they belong to a particular character class – that is, whether they contains strings, integers, objects or Booleans.

Table A outlines the more useful functions available in this category and provides explanations and usage examples.

Table A

Function

Explanation

Example

empty($var)

This function is used to check if a variable is empty (no value or a zero value)

Use this function to check user input — for example, form variables — to ensure that they contain valid data.

<?php
// returns false

$var = "hello";

echo empty($var) ? "true" : "false";

// returns true
$var = 0000;

echo empty($var) ? "true" : "false";

?>
gettype($var)

This function returns the type of a variable – for example, "string", "integer", "Boolean", "float" etc.

Use this function to verify that variables are of the type you expect, usually before inserting them into a strictly-typed database field.

<?php
// returns string
$var = "hello";
echo gettype($var);
// returns double
$var = 1000.56;

echo gettype($var);

?>
is_bool($var)

This function tests a variable to see if it contains a Boolean (true/false) value

Use this function to check if a variable is a Boolean variable.

<?php
// returns true

$var = false;
echo is_bool($var) ? "true" : "false";
?>
is_string($var)

This function tests a variable to see if it is a string.

Use this function to check if a variable holds string data.

<?php
// returns true
$var = "exception";
echois_string($var) ? "true" : "false"

// returns true
$var = "88408";
echo is_string($var) ? "true" :"false";

?>
is_numeric($var)

This function tests a variable to see if it contains a number or numeric string (strings containing a sign, numbers and decimal points).

Use this function to verify that a variable contains a number, usually before using it in a calculation.

<?php
// returns true

$var = "+99.766";

echois_numeric($var) ? "true" :"false";

// returns false

$var = "b00";
echo is_numeric($var) ?"true":"false";
?>
is_array($var)

This function tests a variable to see if it is a PHP associative or numerically-indexed array.

Use this function to check if a variable is an array, usually prior to processing it in a loop.

<?php
// returns true
$var = array("tiger", "lion","zebra");
echois_array($var) ? "true" : "false"; // returns false
$var = "zebra";

echo is_array($var) ? "true" : "false";
?>
is_null($var)

This function tests a variable to see if it is NULL.

Use this function to verify if a variable is NULL or not, usually when evaluating data returned by an SQL query.

<?php
// returns false

$var = "aa";

echo is_null($var) ? "true" : "false";
// returns true
$var = null;
echo is_null($var) ? "true" : "false";

?>
is_object($var)

This function tests a variable to see if it is a PHP object.

Use this function to test if a variable is a PHP object, usually before calling a method or accessing a property.

<?php
// returns false

$var = "exception";
echo is_object($var) ? "true" : "false";
// returns true
$var = new Exception;

echois_object($var) ? "true" : "false";

?>
isset($var)

This function tests a variable to see if it has already been defined.

Use this function to test if a variable has been defined, usually when evaluating the results of a form submission.

<?php
// returns true

$var = "yes";

echoisset($var) ? "true" : "false";
// returns false
echo isset($test) ? "true" : "false";

?>
print_r($var)

This function prints the contents of a variable.

Use this function to "look inside" a variable, typically when debugging a script.

<?php
$var = array("one", "two", array("red", "green"), new Exception, 467);

print_r($var);

?>

三平语录 —- 不定期更新.(6-15更新)

版权所有,转载请注明来自三平的blog http://hi.baidu.com/tecent

三平语录,取之生活,用之生活.

1: 水瓶座的开始纯洁的象水瓶里的水, 当进入社会的大染缸后, 纯洁的变YD,
    YD的就变成了 YDK (YD乃淫荡,YDK乃 YD KING)

2: 找房子那些事   => 房事

3: 找房子? 上找"黄"网啊.

4: 你之所以觉得世界拥挤,那是因为你胖

5: 想创业?就去参加淫在中国.

6: 最羡慕武侠里的那些某某教的教主,千秋万代,一统江湖. 多么风光啊.今天我终于实现了这个梦想
     荣登教主宝座, 我成立的是淫教.

7: 你美若天仙中脸先着地的那位.

8: 生理入门片<<玉女心经>>, 生理入门书<<玉女痛经>>

9: 当今社会,保险公司遍地开花. 这不最近我也开了家保险公司.取名: 中国秦寿保险公司

10: 去年被日此门中, 人面兽心相映红
      人面不知何处去, 禽兽依旧叫春风.

11:每当看到Lux(力士)的广告,我总想给自己的电脑装个Linux

12: 每当看到六神的广告,我就六神无主

13: 吃什么就是什么

14: 本人因为太瘦,人送外号: 禽瘦

15: 咸鱼 =》 泡脚

Keycode对照表

Keycode对照表
字母和数字键的键码值(keyCode)
按键 键码 按键 键码 按键 键码 按键 键码
A 65 J 74 S 83 1 49
B 66 K 75 T 84 2 50
C 67 L 76 U 85 3 51
D 68 M 77 V 86 4 52
E 69 N 78 W 87 5 53
F 70 O 79 X 88 6 54
G 71 P 80 Y 89 7 55
H 72 Q 81 Z 90 8 56
I 73 R 82 0 48 9 57

  

数字键盘上的键的键码值(keyCode) 功能键键码值(keyCode)
按键 键码 按键 键码 按键 键码 按键 键码
0 96 8 104 F1 112 F7 118
1 97 9 105 F2 113 F8 119
2 98 * 106 F3 114 F9 120
3 99 + 107 F4 115 F10 121
4 100 Enter 108 F5 116 F11 122
5 101 - 109 F6 117 F12 123
6 102 . 110
7 103 / 111

  

控制键键码值(keyCode)
按键 键码 按键 键码 按键 键码 按键 键码
BackSpace 8 Esc 27 Right Arrow 39 -_ 189
Tab 9 Spacebar 32 Dw Arrow 40 .> 190
Clear 12 Page Up 33 Insert 45 /? 191
Enter 13 Page Down 34 Delete 46 `~ 192
Shift 16 End 35 Num Lock 144 [{ 219
Control 17 Home 36 ;: 186 | 220
Alt 18 Left Arrow 37 =+ 187 ]} 221
Cape Lock 20 Up Arrow 38 ,< 188 ‘" 222
多媒体键码值(keyCode)
按键 键码 按键 键码 按键 键码 按键 键码
音量加 175
音量减 174
停止 179
静音 173
浏览器 172
邮件 180
搜索 170
收藏 171
2008-05-15程序设计

没有评论
52 views

_default_ VirtualHost overlap on port 80, the first has precedence

使用Apache配置虚拟主机出现_default_ VirtualHost overlap on port 80, the first has precedence错误的解决方案:

I’d like to share with time consuming problem I had last days with vHosts on Apache2 on openSuse linux. Maybe my solution will be helpful for someone, cause believe me, it’s was not easy to find solution (especially using “tries and faults” method).

So my point was to create and successful run few vHosts on my newly settled up Apache2 server. So I’ve created this vHost directives in /etc/apache2/vhosts.d/vhosts.conf :

<virtualhost *:80>
ServerAdmin webmaster@somedomain.com
DocumentRoot /srv/www/somedomain
ServerName www.somedomain.com
ServerAlias somedomain.com
</virtualhost>
<virtualhost *:80>
ServerAdmin webmaster@elsedomain.com
DocumentRoot /srv/www/elsedomain
ServerName www.elsedomain.com
ServerAlias elsedomain.com
</virtualhost>
<virtualhost *:80>
ServerAdmin webmaster@otherdomain.com
DocumentRoot /srv/www/otherdomain
ServerName www.otherdomain.com
ServerAlias otherdomain.com
</virtualhost>

After this, I had to also put new statements into /etc/hosts :

127.0.0.1     www.somedomain.com
127.0.0.1 somedomain.com
127.0.0.1 www.elsedomain.com
127.0.0.1 elsedomain.com
127.0.0.1 www.otherdomain.com
127.0.0.1 otherdomain.com

That’s all. Then I’ve restart apache service, by:

apache2ctl restart

and here’s the result (and the problem itself) :

[Wed Jul 25 21:42:59 2007]
[warn] _default_ VirtualHost overlap on port 80, the first has precedence

What does it mean? The first vHost directive was treat as default one, and somehow every second vHost directive was in conflict with the default one. The The result of this conflict was, that after calling conflicted (means not the default ones) host name URL in browser (”elsedomain.com”, “otherdomain.com”) I got the content (main page) of the default host: “somedomain.com”.

So I hope the problem is clear. And here is what also didn’t work out:
* changing vHosts directive to:

<virtualhost *:*>
[...]
</virtualhost>

* changing vHosts directive to:

<virtualhost 127.0.0.1:*>
[...]
</virtualhost>

* changing vHosts directive to:

<virtualhost 127.0.0.1:80>
[...]
</virtualhost>

* changing IP address in /etc/hosts to 127.0.0.2 and vHosts directive to:

<virtualhost 127.0.0.2:80>
[...]
</virtualhost>

What does really help was something else. I’ve to add new line in the top of my vhosts.conf file:

NameVirtualHost 127.0.0.1

and modify all vHosts sections this way:

<virtualhost 127.0.0.1:80>
[...]
</virtualhost>

It was clear for me that “NameVirtualHost” should be there somewhere. Nevertheless, was very hard to find out that for default in Apache2 (or at least in his SUSE10.2 distribution) this directive is gone for default. Changing ‘*’ mark to localhost IP address (127.0.0.1) goes without saying.

So if You have problem with this warning above I’ve notice, my method should be helpful for You.

Greets

2008-05-12生活记事

1条评论
0 views

Bless…

             今年事情太多
             希望大家都平平安安

phpcms 2007 sp6 中 Table ‘phpcms.table_module’ doesn’t exist 解决方案.

安装的时候我数据库前缀留空
啥都没写
会报这样的错误
Table ‘phpcms.table_module’ doesn’t exist

我下载了一个phpcms2007_sp4_gbk版的,可是在安装过程中出现了下面的错误

MySQL Query:SELECT module,name,iscore,iscopy,isshare,moduledir,moduledomain FROM TABLE_MODULE WHERE disabled=0
MySQL Error:Table ‘phpcms.table_module’ doesn’t exist

把数据库前缀加上就不会报错了
如果数据库前缀首字母为大写字母也会导致这种错误.
把大写换成小写就ok了。

HTTP协议的状态码

HTTP协议的状态码

1**:请求收到,继续处理
2**:操作成功收到,分析、接受
3**:完成此请求必须进一步处理
4**:请求包含一个错误语法或不能完成
5**:服务器执行一个完全有效请求失败

100——客户必须继续发出请求
101——客户要求服务器根据请求转换HTTP协议版本

200——交易成功
201——提示知道新文件的URL
202——接受和处理、但处理未完成
203——返回信息不确定或不完整
204——请求收到,但返回信息为空
205——服务器完成了请求,用户代理必须复位当前已经浏览过的文件
206——服务器已经完成了部分用户的GET请求

300——请求的资源可在多处得到
301——删除请求数据
302——在其他地址发现了请求数据
303——建议客户访问其他URL或访问方式
304——客户端已经执行了GET,但文件未变化
305——请求的资源必须从服务器指定的地址得到
306——前一版本HTTP中使用的代码,现行版本中不再使用
307——申明请求的资源临时性删除

400——错误请求,如语法错误
401——请求授权失败
402——保留有效ChargeTo头响应
403——请求不允许
404——没有发现文件、查询或URl
405——用户在Request-Line字段定义的方法不允许
406——根据用户发送的Accept拖,请求资源不可访问
407——类似401,用户必须首先在代理服务器上得到授权
408——客户端没有在用户指定的饿时间内完成请求
409——对当前资源状态,请求不能完成
410——服务器上不再有此资源且无进一步的参考地址
411——服务器拒绝用户定义的Content-Length属性请求
412——一个或多个请求头字段在当前请求中错误
413——请求的资源大于服务器允许的大小
414——请求的资源URL长于服务器允许的长度
415——请求资源不支持请求项目格式
416——请求中包含Range请求头字段,在当前请求资源范围内没有range指示值,请求
也不包含If-Range请求头字段
417——服务器不满足请求Expect头字段指定的期望值,如果是代理服务器,可能是下
一级服务器不能满足请求

500——服务器产生内部错误
501——服务器不支持请求的函数
502——服务器暂时不可用,有时是为了防止发生系统过载
503——服务器过载或暂停维修
504——关口过载,服务器使用另一个关口或服务来响应用户,等待时间设定值较长
505——服务器不支持或拒绝支请求头中指定的HTTP版本

2008-05-07生活记事

1条评论
0 views

最近…..

spanishpod.com

frenchpod.com

接下来是哪个pod?
Merge很烦.
尤其是在一个稳定版本都没有的时候
来了N个Branches

Bug改不尽,春风吹又生.
秋风扫落叶,红叶都枫了.

空间名称也换成了三平流浪记
总想和三毛这位名人扯上关系
哪一天我赚钱了赚钱了
不再流浪流浪

上海是我的起点
但绝对不是我的终点

这年头出轨并不可怕
可怕的是被撞到

无论遇到什么困难
一定要好好活着
人生无常
一瞬间即可灰灰湮灭

在转角遇见了谁?
也许是一辆集装箱卡车
也许是842
也许是一坨.
总之过马路要小心
红灯行绿灯停
那是不对的.

周末一定要去买个床垫.
每天都睡在木板上
这不是在练功.

家中椅子该换了
桌子太矮
椅子太高
这样腰会很不好
腰不好,肾也会不好

天气热了
会流汗了
要谨记:
每天一斤水
强壮中国人

品冠的新专辑<那些女孩教我的事>
好听
我天天听
你要不要一下

自从搬了住处
睡眠质量很好
每天6点准时醒
那绝对不是我以前的风格
人生最高境界也许就是:
数钱数到脚抽筋
睡觉睡到自然醒

不过突然发现
走路30分钟是不是太漫长了
难道我又想搬了
这次绝对不了.

返回顶部