Table of Contents
周六干点儿啥,干点儿啥
显示隐藏元素的内容
修改可见“水果”的背景色
Home php教程 php手册 周六干点儿啥,干点儿啥

周六干点儿啥,干点儿啥

Jun 13, 2016 am 08:52 AM
girl Movie result clothing

周六干点儿啥,干点儿啥

  hi

又到周六,结果这周没有电影去看,没有衣服去买,没有妹子...当我没说

1、正则表达式-完结篇

---工具类开发---

 

/*
* PHP 正则表达式工具类
* 描述:进行正则表达式匹配,有常用的正则表达式以及允许用户自定义正则表达式进行匹配
*/

class regexTool{
//定义常用正则表达式,并用数组对的方式存储
private $validate=array(
'require' => '/.+/',
'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/',
'currency' => '/^\d+(\.\d+)?$/',
'number' => '/^\d+$/',
'zip' => '/^\d{6}$/',
'integer' => '/^[-\+]?\d+$/',
'double' => '/^[-\+]?\d+(\.\d+)?$/',
'english' => '/^[A-Za-z]+$/',
'qq' => '/^\d{5,11}$/',
'mobile' => '/^1(3|4|5|7|8)\d{9}$/',
);
//定义其他属性
private $returnMatchResult=false; //返回类型判断
private $fixMode=null; //修正模式
private $matches=array(); //存放匹配结果
private $isMatch=false;

//构造函数,实例化后传入默认的两个参数
public function __construct($returnMatchResult=false,$fixMode=null){
$this->returnMatchResult=$returnMatchResult;
$this->fixMode=$fixMode;
}

//判断返回结果类型,为匹配结果matches还是匹配成功与否isMatch,并调用返回方法
private function regex($pattern,$subject){
if(array_key_exists(strtolower($pattern), $this->validate))
$pattern=$this->validate[$pattern].$this->fixMode; //判断后再连接上修正模式作为匹配的正则表达式
$this->returnMatchResult ?
preg_match_all($pattern, $subject,$this->matches):
$this->isMatch=preg_match($pattern, $subject)===1;
return $this->getRegexResult();
}

//返回方法
private function getRegexResult(){
if($this->returnMatchResult){
return $this->matches;
}else{
return $this->isMatch;
}
}

//允许用户自定义切换返回类型
public function toggleReturnType($bool=null){
if(empty($bool)){
$this->returnMatchResult=!$this->returnMatchResult;
}else{
$this->returnMatchResult=is_bool($bool) ? $bool : (bool)$bool;
}
}

//下面则是数据验证方法
public function setFixMode($fixMode) {
$this->fixMode = $fixMode;
}

public function noEmpty($str) {
return $this->regex('require', $str);
}

public function isEmail($email) {
return $this->regex('email', $email);
}

public function isMobile($mobile) {
return $this->regex('mobile', $mobile);
}

public function check($pattern, $subject) {
return $this->regex($pattern, $subject);
}
}

实例化进行验证

/*
* PHP 正则表达式验证文件
*/
//包含类定义文件
require_once 'regexTool.class.php';

$regex=new regexTool();
$regex->setFixMode('U'); //设定修正模式为懒惰模式U
$r=$regex->isEmail('asdfads@qq.com');
show($r);

//使用之前学过的show函数来进行验证
/*
* Description:PHP 正则表达式函数
*
* @name:show
* @description:output debug
* @param $var:input data
* @return void
*
*/

function show($var=null){
if(empty($var)){
echo 'null';
}elseif(is_array($var)||is_object($var)){
//array,object
echo '

';<br>		print_r($var);<br>		echo '
Copy after login
';
}else{
//string,int,float...
echo $var;
}
}

---验证表单---

即使用方法之一

html写文件如下





用户注册



用户名


email


手机号





相对应的在regCheck.php中改

if(!$regex->noEmpty($_POST['username'])) exit('用户名为空');

---仿(山寨版)smarty简易模板引擎---

--允许程序猿分前端后端分开开发

--模板引擎工作原理:获取模板源文件,编译模板,输出给用户(也就是联系起前后端,做“接口”一样)

--模式单元:总模式,即$pattern;子模式,即()中的东西,即一个自定义的原子,也成为模式单元

具体应用中,preg_match_all会匹配到两种模式

preg_match_all结果为二维数组,其中$matches[0][0]为总模式

其他为子模式

--

 

 

 

 

2、jQuery

---简介---

JQuery是继prototype之后又一个优秀的Javascript库。它是轻量级的js库 ,它兼容CSS3,还兼容各种浏览器(IE 6.0+, FF1.5+, Safari 2.0+, Opera 9.0+),jQuery2.0及后续版本将不再支持IE6/7/8浏览器。jQuery使用户能更方便地处理HTML(标准通用标记语言下的一个应用)、events、实现动画效果,并且方便地为网站提供AJAX交互。jQuery还有一个比较大的优势是,它的文档说明很全,而且各种应用也说得很详细,同时还有许多成熟的插件可供选择。jQuery能够使用户的html页面保持代码和html内容分离,也就是说,不用再在html里面插入一堆js来调用命令了,只需要定义id即可。 jQuery是一个兼容多浏览器的javascript库,核心理念是write less,do more(写得更少,做得更多)。jQuery在2006年1月由美国人John Resig在纽约的barcamp发布,吸引了来自世界各地的众多JavaScript高手加入,由Dave Methvin率领团队进行开发。如今,jQuery已经成为最流行的javascript库,在世界前10000个访问最多的网站中,有超过55%在使用jQuery。 jQuery是免费、开源的,使用MIT许可协议。jQuery的语法设计可以使开发者更加便捷,例如操作文档对象、选择DOM元素、制作动画效果、事件处理、使用Ajax以及其他功能。除此以外,jQuery提供API让开发者编写插件。其模块化的使用方式使开发者可以很轻松的开发出功能强大的静态或动态网页。 jQuery,顾名思义,也就是JavaScript和查询(Query),即是辅助JavaScript开发的库。(摘选自百度百科) --环境搭建 下载1.9.0稳定版本,保存在本地就好,然后再用javascript的时候包含进就行了 --初体验 jQuery就是js的函数封装,形成库(私以为其更利于对付对象) 相比于原JS,它一般来说更简便




#id选择器




div的内容

Hello world!




这里$()表示匹配一定字符内的元素

---基础选择器---

--#id选择器

div的内容


基本使用方法是$("#id")

--element选择器

根据元素的名称可以查找到该元素,并调用css()、attr()等方法设置对所取元素的操作。


--.class选择器

根据类的名称选择元素,其他操作类似

立正,向我这边看齐

我先歇歇脚


--*选择器

选择器中的参数就一个“*”,既没有“#”号,也没有“.”号。 由于该选择器的特殊性,它常与其他元素组合使用,表示获取其他元素中的全部子元素。

实践证明,由于使用*选择器获取的是全部元素,因此,有些浏览器将会比较缓慢,这个选择器也需要谨慎使用。








--sele1,sele2,seleN选择器

有时需要精确的选择任意多个指定的元素,类似于从文具盒中挑选出多根自已喜欢的笔,就需要调用sele1,sele2,seleN选择器,它的调用格式如下:

$(“sele1,sele2,seleN”)

其中参数sele1、sele2到seleN为有效选择器,每个选择器之间用“,”号隔开,它们可以是之前提及的各种类型选择器,如$(“#id”)、$(“.class”)、$(“selector”)选择器等。

选我吧!我是red

选我吧!我是green

选我吧!我是blue


--ance desc选择器

本节开始,我们将介绍层次性选择器。

在实际应用开发中,常常是多个元素嵌套在一起,形成复杂的层次关系,通过层次选择器,可以快速定位某一层次的一个或多个元素,ance desc选择器就是其中之一,它的调用格式如下:

$("ance desc")

其中ance desc是使用空格隔开的两个参数。ance参数(ancestor祖先的简写)表示父元素;desc参数(descendant后代的简写)表示后代元素,即包括子元素、孙元素等等。两个参数都可以通过选择器来获取。比如家族姓氏“div”,家族几代人里,都有名字里带“span”的,就可以用这个ance desc选择器把这几个人给定位出来。

码农家族







--parent>child选择器

与上一节介绍的ance desc选择器相比,parent > child选择器的范围要小些,它所选择的目标是子集元素,相当于一个家庭中的子辈们,但不包括孙辈,它的调用格式如下:

$(“parent > child”)

child参数获取的元素都是parent选择器的子元素,它们之间通过“>”符号来表示一种层次关系。


码农家族









--prev+next选择器

俗话说“远亲不如近邻”,而通过prev + next选择器就可以查找与“prev”元素紧邻的下一个“next”元素,格式如下:

$(“prev + next”)

其中参数prev为任何有效的选择器,参数“next”为另外一个有效选择器,它们之间的“+”表示一种上下的层次关系,也就是说,“prev”元素最紧邻的下一个元素由“next”选择器返回的并且只返回唯的一个元素。


码农家族







注意,这里的next是要输入下一个要找的分类器标识,不是直接输入next

--prev~siblings选择器

与上一节中介绍的prev + next层次选择器相同,prev ~ siblings选择器也是查找prev 元素之后的相邻元素,但前者只获取第一个相邻的元素,而后者则获取prev 元素后面全部相邻的元素,它的调用格式如下:

$(“prev ~ siblings”)

其中参数prev与siblings两者之间通过“~”符号形成一种层次相邻的关系,表明siblings选择器获取的元素都是prev元素之后的同辈元素。


码农家族







---过滤性选择器---

--:first/:last过滤选择器

本章我们介绍过滤选择器,该类型的选择器是根据某过滤规则进行元素的匹配,书写时以“:”号开头,通常用于查找集合元素中的某一位置的单个元素。

在jQuery中,如果想得到一组相同标签元素中的第1个元素该怎样做呢?

在下面的示例代码中你可能注意到我们会使用

 $(“li:first”)

注意:书写时以“:”号开头。

改变最后一行"苹果"背景颜色:


  1. 葡萄

  2. 香蕉

  3. 橘子

  4. 西瓜

  5. 苹果



--:eq(index)过滤选择器

如果想从一组标签元素数组中,灵活选择任意的一个标签元素,我们可以使用

:eq(index)

其中参数index表示索引号(即:一个整数),它从0开始,如果index的值为3,表示选择的是第4个元素

改变中间行"葡萄"背景颜色:


  1. 橘子

  2. 香蕉

  3. 葡萄

  4. 苹果

  5. 西瓜



--:contains(text)过滤选择器

与上一节介绍的:eq(index)选择器按索引查找元素相比,有时候我们可能希望按照文本内容来查找一个或多个元素,那么使用:contains(text)选择器会更加方便, 它的功能是选择包含指定字符串的全部元素,它通常与其他元素结合使用,获取包含“text”字符串内容的全部元素对象。其中参数text表示页面中的文字。

改变包含"jQuery"字符内容的背景色:


  1. 强大的"jQuery"

  2. "javascript"也很实用

  3. "jQuery"前端必学

  4. "java"是一种开发语言

  5. 前端利器——"jQuery"



--:has(selector)过滤选择器

除了在上一小节介绍的使用包含的字符串内容过滤元素之外,还可以使用包含的元素名称来过滤,:has(selector)过滤选择器的功能是获取选择器中包含指定元素名称的全部元素,其中selector参数就是包含的元素名称,是被包含元素。

改变包含"label"元素的背景色:


  1. 我是P先生



  2. 我也是P先生



  3. P先生就是我哦




--:hidden过滤选择器

:hidden过滤选择器的功能是获取全部不可见的元素,这些不可见的元素中包括type属性值为hidden的元素。

显示隐藏元素的内容





--:visible过滤选择器

与上一节的:hidden过滤选择器相反,:visible过滤选择器获取的是全部可见的元素,也就是说,只要不将元素的display属性值设置为“none”,那么,都可以通过该选择器获取。

修改可见“水果”的背景色



  • 橘子

  • 香蕉

  • 葡萄

  • 苹果

  • 西瓜



--

 

 

 

 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The racing movie 'Gran Turismo' is released in mainland theaters today, with a Rotten Tomatoes freshness score of 63% The racing movie 'Gran Turismo' is released in mainland theaters today, with a Rotten Tomatoes freshness score of 63% Sep 10, 2023 pm 08:33 PM

According to news from this site on September 1, the passionate racing action movie "Gran Turismo" was officially released today. The film is adapted from the true legendary experience of PlayStation gamers becoming professional racing drivers. Neil Blom, the director of "District 9" Directed by Camp. This website noticed that "Gran Turismo: Speed" has a Rotten Tomatoes freshness score of 63% and a popcorn value of 98%; the film and television rating website CinemaScore has an A audience rating, and the global box office has exceeded US$56 million. The film tells the story of an ordinary gaming boy who tries his best to chase the unattainable dream of racing. Without being favored by the outside world, he relies on his talent, hard work and love to constantly challenge the limits in the real arena of life and death, surpassing his opponents, and finally succeeds in becoming a racer. An unknown gamer becomes

'Digimon Adventure 02 THE BEGINNING' preview image released, will be released in Japan on October 27 'Digimon Adventure 02 THE BEGINNING' preview image released, will be released in Japan on October 27 Sep 04, 2023 pm 03:57 PM

This website reported on September 1 that a new preview image of the theatrical version of "Digimon Adventure 02 THEBEGINNING" has been released and will be released in Japan on October 27. This website noticed that the theatrical version had previously released a trailer. In addition to Daisuke, V-Zimon and other protagonists, the protagonist Rui Owada made his debut. The trailer projected the stage "Mitsuoka" where the "Digimon" series began. Starting from the appearance of the protagonist Taichi Yagami and his sister Hikari from "Digimon Adventure", the "irreplaceable" bond was "revealed." At the same time, nostalgic Digimon such as Angemon, Ankylomon, and Aquimon have appeared one after another, as well as Emperordramon (dragon mode), Fairymon, Lighteater, etc. Plot introduction: This world is full of possibilities. The several worlds presented before my eyes sometimes gave me

The concept trailer of 'Bear Bears Reversal of Time and Space' is released and will be released on the first day of the Lunar New Year in 2024 The concept trailer of 'Bear Bears Reversal of Time and Space' is released and will be released on the first day of the Lunar New Year in 2024 Oct 27, 2023 pm 09:13 PM

According to news from this website on October 27, The Bears officially announced the concept trailer of "The Bears Reversal of Time and Space", which will be released on the first day of the Lunar New Year in 2024 (February 10). This website noticed that "Bear Bears: Reverse Time and Space" is the 10th film in the "Bear Bears" series of movies, produced by Huaqiang Fantawild (Shenzhen) Animation Co., Ltd. It can be seen from the trailer that Bald Qiang has changed from a lumberjack to a "worker" in the office. As Bald Qiang sits on the seat wearing a "mysterious instrument", "Bear Infested: Treasure Hunt", " "Bear Bears: Bear Wind", "Bear Haunted - Fantasy Space", "Bear Haunted - Primitive Era", "Bear Haunted - Wild Continent", "Bear Haunted - Return to Earth", "Bear Haunted - Come with Me" "Bear Core" and other movie clips flashed by. Plot synopsis: Baldhead

The movie 'Sakamoto Ryuichi: Masterpiece' is scheduled to be released nationwide on May 31, recording his last piano concert. The movie 'Sakamoto Ryuichi: Masterpiece' is scheduled to be released nationwide on May 31, recording his last piano concert. May 09, 2024 pm 03:55 PM

This website reported on May 9 that the movie "Sakamoto Ryuichi: The Masterpiece" released a finalized poster, confirming that it will be released nationwide on May 31. It contains 20 classic tracks and is approximately 103 minutes long. This film gained a lot of popularity and reputation when it was screened at the Beijing Film Festival. The music flows, recreating the movement of life. The person has passed away, but the music is endless. This website noticed that this movie will be available in 2D, CINITY, CINITYLED versions and Dolby Atmos versions for viewers to choose from. The famous Japanese composer, music producer, singer, actor and pianist Mr. Ryuichi Sakamoto passed away in Tokyo on March 28, 2023 at the age of 71. In order to deeply remember and commemorate the legendary music career of this world-class artist, director Sora Ono (himself the child of Sakamoto Ryuichi) recorded

The mobile movie 'Hua Jing' is about to be released: the entire film was shot using Huawei Pura70 series The mobile movie 'Hua Jing' is about to be released: the entire film was shot using Huawei Pura70 series Jul 16, 2024 pm 09:04 PM

According to news on July 15, He Gang, CEO of Huawei Terminal BG, announced today that the mobile phone movie "Hua Jing" co-created by Huawei and director Zhao Xiaoding will be released soon. He added: "Since we joined hands with the Golden Rooster Film Festival in 2019 to launch the 'Huawei Imaging·Golden Rooster Mobile Film Project', we have received more than 10,000 entries. The colorful works have allowed me to see what can be achieved by shooting movies with mobile phones. Possibilities and narrative depth.” As can be seen from the poster, the film is promoted as “shot by Huawei Pura70 series” and the poster is in black and white style. It is understood that Zhao Xiaoding is Zhang Yimou’s royal photographer and has worked on many Zhang Yimou films.

The space thriller film 'Alien: The Last Ship' is confirmed to be introduced to the Mainland, the schedule is to be determined The space thriller film 'Alien: The Last Ship' is confirmed to be introduced to the Mainland, the schedule is to be determined Jul 18, 2024 am 07:26 AM

According to news from this website on July 15, 20th Century Pictures issued an official announcement today that the science fiction horror film "Alien: The Last Ship" has been confirmed to be introduced to the mainland, and the schedule is to be determined. The mainland schedule of "Alien: Death Ship" has not yet been announced. It will be released in Hong Kong on August 15, 2024, and in the United States on August 16. According to inquiries on this site, the film is directed by Fede Alvarez and stars the following actors: Carly Spaeny, Isabella Merced, Archie Reynolds, David Ronson, Spike Finn The film tells the story: The fear of being dominated by aliens and facehuggers strikes again! In the unknown depths of space, changes occur quietly, and fatal misfortunes unexpectedly occur... The countdown to a desperate escape begins.

The space thriller movie 'Alien' scored 7.7 on Douban, and the box office exceeded 100 million the day after its release. The space thriller movie 'Alien' scored 7.7 on Douban, and the box office exceeded 100 million the day after its release. Aug 17, 2024 pm 10:50 PM

According to news from this website on August 17, the space thriller "Alien: The Last Ship" by 20th Century Pictures was released in mainland China yesterday (August 16). The Douban score was announced today as 7.7. According to real-time data from Beacon Professional Edition, as of 20:5 on August 17, the film’s box office has exceeded 100 million. The distribution of ratings on this site is as follows: 5 stars account for 20.9% 4 stars account for 49.5% 3 stars account for 25.4% 2 stars account for 3.7% 1 stars account for 0.6% "Alien: Death Ship" is produced by 20th Century Pictures , Ridley Scott, the director of "Blade Runner" and "Prometheus", serves as the producer, directed by Fede Alvare, written by Fede Alvare and Rodo Seiagues, and Card Leigh Spaeny, Isabella Merced, Aileen Wu, Spike Fey

The trailer for Disney's new film 'Inside Out 2' broke a record with 157 million views in 24 hours, surpassing 'Frozen 2' The trailer for Disney's new film 'Inside Out 2' broke a record with 157 million views in 24 hours, surpassing 'Frozen 2' Nov 11, 2023 pm 12:33 PM

The content that needs to be rewritten on this site is: 11 The content that needs to be rewritten is: The content that needs to be rewritten is: 11 The content that needs to be rewritten is: According to Japanese news, Disney officially announced that the content that needs to be rewritten for "Inside Out" is: :2"'s trailer received 1.57 billion views in 24 hours, surpassing "Frozen" The content that needs to be rewritten is: 2》The content that needs to be rewritten is: the content that needs to be rewritten in 2019 is: the record set in 2019 (1.164 The content that needs to be rewritten is: billion times). Pixar chief creative officer Pete Docter said: "We are delighted that so many people are watching "Head".

See all articles