![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
php
工程思
学好一切
展开
-
php 中静态变量static 全局常量const的使用注意事项
static 静态变量如 public function static $first = "first";只能用self::$first调用const常量不能定义在方法内部,常量没有$如const M_STR = "str";用self::M_STR调用原创 2013-04-26 16:37:40 · 1203 阅读 · 1 评论 -
PHP中$_SERVER参考手册
$_SERVER['PHP_SELF'] #当前正在执行脚本的文件名,与 document root相关。$_SERVER['argv'] #传递给该脚本的参数。 $_SERVER['argc'] #包含传递给程序的命令行参数的个数(如果运行在命令行模式)。 $_SERVER['GATEWAY_INTERFACE'] #服务器使用的 CGI 规范的版本。例如,“CGI/1.1”。$转载 2013-05-28 10:45:50 · 586 阅读 · 0 评论 -
中文字符串截取无乱码方法定义
class StringComponent{public static function cutString($sourceStr, $cutLength = 10, $extStr = '...'){$returnStr = ''; $i = 0; $n = 0;$strLength = strlen($sourceStr);if ($strLength > $cutLeng原创 2013-09-18 09:43:44 · 565 阅读 · 0 评论 -
php global define const static 等关键字的定义
1. global 全局变量,定义在函数中的全局变量,必须使用了该函数,内部的全局变量才能够在外部使用2.define 常量的定义,define('名字,最好大写', 'value', true);不知道能不能在类中定义(测试之后发现,不能在类中定义,只能在类外定义),使用常量的时候不能加$和self::。3.const 类常量的定义,可以在类外定义(好像是5.3之后就可以了,反正现在是可原创 2013-10-18 11:08:47 · 1007 阅读 · 0 评论 -
php 自定义错误error_function 的建立
所有代码演示如下:<?php function errorWarning($errev, $errorms){ echo "$errev: $errorms"; } set_error_handler("errorWarning"); //加载到默认系统错误处理程序 echo $ss; ?>原创 2013-11-12 11:09:57 · 633 阅读 · 0 评论 -
php cookie 的使用和注意事项
setCookie() 设置cookie注释: setCookie()函数必须位于标签之前语法setCookie(name, value, expire, path, domain, secure);说明:name->cookie名称value->cookie保存的值expire->规定 cookie 的有效期。path->cookie 的服务器路径do原创 2013-11-12 10:31:03 · 720 阅读 · 0 评论 -
php 正则获取img所有属性值,包括src等,保存一个,我不懂正则啊
php/*PHP正则提取图片img标记中的任意属性*/$str = 'PHP正则提取或更改图片img标记中的任意属性';//1、取整个图片代码preg_match('/]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$str,$match);echo $match[0];//2、取widthpreg_match('//i',$str,$match);e转载 2014-03-27 16:39:52 · 1726 阅读 · 0 评论