随笔分类 - php
php 平时要注意的细节问题
摘要:标记之前,不会显示出整个表格。一些版本的 Microsoft Internet Explorer 只有当接受到的256个字节以后才开始显示该页面,所以必须发送一些额外的空格来让这些浏览器显示页面内容。 */void ob_implicit_flush([int $flag = true])/* 打...
阅读全文
摘要:$str = "lin == 3615";$pattern = "/(.*)/";$str = preg_replace($pattern, "$1", $str);print_r($str);$pattern 中没有问号结果为:lin == 3615$str = "lin == 3615";$pattern = "/(.*?)/";$str = preg_replace($pattern, "$1", $str);print_r($str);$pattern 中有问号(相当
阅读全文
摘要:$v) { $a[$k] = t($v); } }else{ $a = $a*10; } return $a;}$ab = t($arr);// 此时数组的每个元素都乘了 10 了print_r($ab);// 结果为Array( [0] => Array ( ...
阅读全文
摘要:name = $name; } public function Show() { echo "装扮" . $this->name; }}//服饰类class Finery extends Person{ protected component; public function Decoration(Person $component) { $this->component = $component; } public function Show() { if($this->component != null) { $this->component-&
阅读全文
摘要:strategy = $strategy; } public function ContextInterface() { $this->strategy->AlgorithmInterface(); }}// 实现过程$context = new Context(new ConcreteStrategyA());$context.ContextInterface();$context = new Context(new ConcreteStrategyB());$context.ContextInterface();$context = new Context(new Concre
阅读全文
摘要:numA = $numA; $this->numB = $numB; } abstract function getResult();}class OperationAdd extends Operation{ public function getResult() ...
阅读全文
摘要:单例类:1、构造函数需要标记为private(访问控制:防止外部代码使用new操作符创建对象),单例类不能在其他类中实例化,只能被其自身实例化;2、拥有一个保存类的实例的静态成员变量3、拥有一个访问这个实例的公共的静态方法(常用getInstance()方法进行实例化单例类,通过instanceo...
阅读全文
摘要:// bool is_dir(string $filename) 判断给定文件名是否是一个目录。// resource opendir(string $path[,resource $context]) // 打开一个目录句柄,可用于之后的 closedir(),readdir() 和 rewind...
阅读全文
摘要:function foo($arg){ $arg_num = func_num_args(); // 获取函数参数的个数 $args = func_get_args(); // 获取函数参数列表,以数组形式返回 $arg = func_get_arg(1); // 获取指定的函数参数 print_r($arg);}foo(1, 2);==============================// 寻找与模式匹配的文件路径// glob(partern[, flag])// flag : // GLOB_MARK - 在每个返回的项目中加一个斜线// GLOB_NOSORT - 按照文件在目录
阅读全文
摘要:数据库配置文件config.php登录首页login.php" method="post">user:pwd:实际登录的页面face.php退出登出页面logout.php
阅读全文
摘要:sess_read()->sess_write() -> sess_close() ->sess_destroy() -> sess_gc()ini_set("session.save_handler", "user"); // 自定义保存方式function sess_open($sess_pa...
阅读全文
摘要:如正则的函数 preg_replace($patern, $replacement, $content) 等等其中如果 $content 中要替换 \ 成 /,必须在 $patern中写成 \\\\,因为首先是 PHP 解析为 \\,再由正则解析为 \,所以必须形如 preg_replace('/[\\\\]{1,}/', '/', $content)其实就是两次解析,一次为 php 引擎解析,一次是 正则解析!
阅读全文
摘要:引用地址 http://www.zzbaike.com/wiki/php-正则表达式: 表示in-casesensitive,即大小写不敏感s: PCRE_DOTALL,表示点号可以匹配换行符。U: 表示PCRE_UNGREEDY,表示非贪婪,相当于perl/python语言的.*?,在匹配过程中,对于.*正则,一有匹配立即执行,而不是等.*消费了所有字符再一一回退。PHP正则表达式模式后面通常带有 /i, /is, /s, /isU等参数,那么这都是些什么东西呢?下面我们一起来看看:i 匹配大小写s 模式中的圆点元字符(.)匹配所有的字符,包括换行符x 模式中的空白字符除了被转义的或在字符类
阅读全文
摘要:数据库设计:create table `header`( // 父表 parent int not null, //父级 poster varchar(20) not null, //作者 posted datetime, //时间 title varchar(100), //标题 childr...
阅读全文
摘要:/** *抓取远程图片到本地 */ // 方法一 $url = ''; $img = file_get_contents($url); file_put_contents('1.png',$img); // 方法二 class Spider { /* * @param string $url,图片路径,如: http://www.xxx.com/1.jpg * @param s...
阅读全文
摘要:true, // return web page 以字符流返回不输出浏览器 // CURLOPT_HEADER => false, // don't return headers // CURLOPT_FOLLOWLOCATION => true, // follow redirects // CURLOPT_ENCODING => "", // handle all encodings //CURLOPT_USERAGENT => "spider", // who am i // CURLOPT_AUTOREFERER
阅读全文
摘要:基本思路:1。HTML表单中 form中的enctype必为enctype="multipart/form-data",method = post 设置提交数据中的type = file2。在处理页面中用$_FILES['upfile']( upfile 为type=file中的name名称);3。
阅读全文
摘要:基本思路是:在生成图片的页面中(as: yzm.php)1。设置生成的图片的宽度和高度;2。设置图片要写入的字符;3。截取显示在图片上的字符;4.开启session,把上面截取的字符存放在session中,用session返回的值与填写的验证码是否相同;5。用imagecreate()生成图片;6。给上面生成的图片绘色,用imagecollorallocate(),第一次调用即为图片的底色;7。再次用imagecollorallocate()定义要用到的颜色;8。用imagestring()给生成的图片填充一些字符;9。再用imagestring()给生成的图片写上上面截取的字符10。用ima
阅读全文