PHP基本知识 正则表达式,伪静态,php图像函数库

PHP基本知识 正则表达式,伪静态,php图像函数库
知识点:
一 正则表达式.
二 伪静态.
三 php图像函数库.

一 正则表达式:
1、正则表达式的基础:
正则表达式:在字符串处理的时候,查找和匹配字符串,
 正则表达式 是用来匹配和查找字符串。
2、ereg(正则表达,"查找匹配的内容",$arr);
在内容当中查找 与正则相匹配的部分,将放入 $arr中。
preg_match(正则表达,"查找匹配的内容",$arr);****
3、正则表达式的元素:
1》原子:普通字符(a--z A--Z 0--9 转义字符)
2》元字符: 具有特殊功能的 特殊字符 *  . ?  +....
3》模式修正符:用字符来表示特定含义,对正则的补充。
i(忽略大小写) m  s .....
4、正则中的原子:
1》a-z A-Z 0-9
正则格式:
$mode = "/正则的内容/模式修正符";
2》(abc) 会看做一个单元存在.
如果带括号:括号中的内容会被放到数组中。
3》[abc] 用[] 表示字符是或的关系。
  [^abc]  ^ 写在[]内 表示排除 除了。
  字符串中不能只含有a 或 b  或 c
  [^0-9]   0-9  <=> 0123456789
  a-z
A-Z
4》转移字符  \
\d  0-9 任意一个数字
\D  除了数字意外任意一个字符.
\w  匹配所有的字符 数字 _   [a-zA-Z0-9_]
\W 匹配特殊符号
\s 回车 换行 分页符号
0-9  [0-9]
(^98) 以后边内容开头。
5 元字符: 具有特殊功能的 特殊字符
*: 匹配前一个内容的任意多次。
注意:()内容会作为一个整体。
.: 任意一个字符 不包括回车和换行。
+:匹配前一个内容1次以上
?:匹配前一个内容 0或1次。
|:或
^:开头符号,写在[] 不能只包含。
$:结尾符号
注意:匹配特定的字符串 开头和结构都是该字符串
^str$
{m}:匹配前一个内容出现m次。
{m,}:匹配前一个内容至少出现m;
{m,n}:匹配前一个内容至少出现m 至多出现n;
() 合并整体,并且是放入内存的。 后边有引用 \1

6 模式修正符:对正则起补充 说明的作用:
i:不区分大小写。
x:忽略正则中的空白。
A:强制从头开始匹配。

练习:匹配日期格式
2012-12-12;


二 伪静态:
****.html  div html css --->静态页面.

****.php 动态网页.
网站:期望盈利。----》访问量---》seo
****.html  ***.htm ***.shtml

1 有利于seo优化。
2 提高网站安全性。
3 伪静态的配置:
apache 当中
apache配置文件
D:\web\apache\conf\httpd.conf
1>去掉前面的#
LoadModule rewrite_module modules/mod_rewrite.so
2> AllowOverride None-->All
  Deny-->Allow from all
3> 230行
  AllowOverride None---》All
4 支持伪静态:
.htaccess windows 不能直接创建。
创建.htaccess文件
对文本文件 另存为 --》.htaccess;
用户:
*.html ---> index.php
RewriteEngine on 开启伪静态。
RewriteRule 正则        index.php
[a-z].html$
view-1.html$  index.php
[a-z]{1,}-([0-9]{1,}).html$  index.php


三 php图像函数库:
做简单 线性图形。---》验证码:
1:php图形函数库的配置:
php.ini
extension=php_gd2.dll -->图形和图像。
2 图形图像函数库
imagecreate
描述:创建基于调色板的图像。
格式:resource imagecreate ( int $x_size , int $y_size )

imagecreatetruecolor
描述: 新建一个真彩色图像
resource imagecreatetruecolor ( int $x_size , int $y_size )

imagegif | imagejpeg | imagepng
描述:将图像以 gif|jpeg|png的格式输入到页面(文件);
imagedestroy
描述:销毁图像在内存中的垃圾。
bool imagedestroy ( resource $image )
imagechar()
描述:水平绘制一个字符。
格式:bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color )
resource $image ,  创建的图像资源
int $font , 字号
int $x , int $y , (x,y)坐标
string $c , 图像上写的字
int $color 颜色。
imagestring();******
描述:水平绘制字符串;
bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )
resource $image ,
int $font ,
int $x , int $y ,
string $s ,
int $col
imagecolorallocate()
描述:为一幅图像分配颜色
int imagecolorallocate ( resource $image , int $red , int $green , int $blue )
resource $image ,
int $red ,   0--255
int $green , 0--255
int $blue 0--255
imagerectangle();
描述:画一个矩形 线框。

bool imagerectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $col )
resource $image ,
int $x1 , int $y1 ,
int $x2 , int $y2 ,
int $col
imagefilledrectangle()
描述:绘制填充矩形。
bool imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
resource $image ,
int $x1 , int $y1 ,
int $x2 , int $y2 ,
int $color

谢谢关注 websites 博客!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云尔Websites

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值