
php
文章平均质量分 69
xiaosi2468
这个作者很懒,什么都没留下…
展开
-
php 接口 与 類
1、接口的介绍与创建 关键字 :interface2、接口的引用与规范 关键字 :implements接口:一种成员属性全部为抽象的特殊抽象类,在程序中同为规范的作用1、类中全部为抽象方法2、抽象方法前不用加abstract3、接口抽象方法属性为public4、成员属性必须为常量抽象:1、类中至少有一个抽象方法2、抽象方法前需加abstract共同点:1、本身都不能被实例化,必须被继承或者引用2、继承或者引用后,需要把所有抽象方法重载方可使用接口有自己的创建关键字:i转载 2010-10-22 17:29:00 · 363 阅读 · 0 评论 -
php strtok()
// string strtok(string input, string separator);原创 2010-11-07 15:38:00 · 844 阅读 · 0 评论 -
php printf() sprintf()
<br /><br /> $n = 43951789; <br /> $u = -43951789; <br /> $c = 65; <br /> printf("%%b = %b/n", $n); <br /> printf("%%c = %c/n", $c); <br /> printf("%%d = %d/n", $n); <br /> printf("%%e = %e/n", $n); <br /> print原创 2010-11-07 12:49:00 · 576 阅读 · 0 评论 -
php nl2br() strtoupper() strtolowe() ucfirst() ucwords()
并换行 echo nl2br($aline); ?>原创 2010-11-06 22:49:00 · 718 阅读 · 0 评论 -
PHP trim ltrim rtrim
<br /><br /> $text = "/t These are a few words :) .. . "; <br /> $hello = "Hello World"; <br /> $binary = "/x09Example String/x0A "; <br />#original <br /> var_dump($text); <br /> echo "/n"; <br />#$text <br /> $trimed = t原创 2010-11-06 22:18:00 · 450 阅读 · 0 评论 -
php 异常处理 throw catch
/n"; if($divisor == 0){ throw new Exception('除数不能为零', 101); } $result = $dividend / $divisor; echo "结果为 $result/n/n"; } catch(Exception $e){ # 类型指示 Except原创 2010-10-30 18:00:00 · 454 阅读 · 0 评论 -
php 内置异常类Exception
<br /><br /> class Exception{ <br /> protected $message = 'Unkown exception'; <br /> protected $code = 0; <br /> protected $file; <br /> protected $line; <br /> function __construct($message = null, $code =原创 2010-10-30 17:58:00 · 735 阅读 · 0 评论 -
php 5 两个对象比较
flag = $flag; } } class OtherFlag{ public $flag; public function __construct($flag = true){ //什么意思呢? $this->flag = $flag; } } $o = new Flag(); $p = new Flag()原创 2010-10-29 22:13:00 · 671 阅读 · 0 评论 -
php set_exception_handler()
getMessage(); } set_exception_handler('exception_handler'); throw new Exception("-> 作为示例,故意抛出一个异常但不捕获它。/n"); echo "这条语句不会被执行。/n"; ?> /* 使用函数set_exception_handler()可以设置异常处理回调函数,该函数原型如下: string set_exception_handle原创 2010-10-31 12:29:00 · 1030 阅读 · 0 评论 -
php 用户自定义异常
getMessage(); $code = $this->getCode(); $file = $this->getFile(); $line = $this->getLine(); $ret = "/n-------------------------------------/n"; $ret .= "有错误发生!/n"; $ret原创 2010-10-30 23:04:00 · 535 阅读 · 0 评论 -
php 5 clone __clone()
a/n"; echo "$subtest->a/n"; $subtest->a = 1; echo "$test->a/n"; echo "$subtest->a/n"; $subtest2 = clone $test; echo "/n$test->a/n"; echo "$subtest2->a/n"; $subtest2->a = 2; echo "$test->a/n";原创 2010-10-29 11:08:00 · 570 阅读 · 0 评论 -
php 5 final方法 final 类
<br /><br />/* <br /> class BaseClass{ <br /> public function test(){ <br /> echo "BaseClass::test() called/n"; <br /> } <br /> final public function moreTesting(){ <br /> echo "BaseClass::moreTes原创 2010-10-28 18:31:00 · 663 阅读 · 0 评论 -
php 类型指示
var; } } class OtherClass{ public $var = 'Hello, World!'; } $obj = new MyClass(); $other = new OtherClass(); $obj->test($other); $obj->test(2); #为什么没有报错呢? ?>原创 2010-10-29 22:22:00 · 323 阅读 · 0 评论 -
php 5 __toString()方法 类转换为字符串
a = $a; $this->b = $b; $this->c = $c; } public function __toString(){ return $this->a.' '.$this->b.' '.$this->c; } } $class = new TestClass('Good', 'morning,', 'Sir!')原创 2010-10-28 18:32:00 · 3008 阅读 · 0 评论 -
php 5 Iterator 内部接口
var = $array; } } public function rewind(){ echo "rewinding/n"; reset($this->var); #reset() 将 array 的内部指针倒回到第一个单元并返回第一个数组单元的值。 } public function current(){原创 2010-10-28 15:10:00 · 426 阅读 · 0 评论 -
php perl风格 正则表达式
/* 查找字符串是正则表达式的主要应用。在php中,可以作用的并且用于匹配perl风格正则表达式的 主要函数是 preg_match()。该函数原型如下 int preg_match(string pattern, string subject[,array matches[,int flags]]) 在subject中搜索pattern。$matches[0]将包含与整个模式匹配的文本, $matches[1]将包含与第一个捕获的括号中的子模式所匹配的原创 2010-10-26 12:44:00 · 382 阅读 · 0 评论 -
php 迭代 遍历对象
$value){ echo "$key => $value"; echo "/n"; } } } $a = new A(); foreach($a as $key => $value){ //类外遍历对象成员 echo '$key'.'=>'."$value"; echo "/n";原创 2010-10-24 23:55:00 · 1280 阅读 · 0 评论 -
php 接口
interface IActivity{ //接口中只需提供方法簽名,不能有成員變量 public function eat(); //接口中所有方法都必須是public方法 public function shout(); } class Animal{ protected $_weight; public function __construct($weight){ $this->_weight = $weight; } } //用 implements 關鍵字聲明實現接口的類原创 2010-10-22 16:30:00 · 373 阅读 · 0 评论 -
strcmp() strcasecmp() strncasecmp() strlen()
<br /><br /> $first = 'Pear'; <br /> $second = "peach"; <br />// int strcmp(string str1, string str2) <br />// CASE SENSITIVE <br /> echo "$first STRCMP $second, result is : "; <br /> echo strcmp($first, $second); <br /> echo原创 2010-11-07 22:24:00 · 667 阅读 · 0 评论