


[Code] Keyword Highlighting
-
<span><span class="keyword">function</span><span> highlight(</span><span class="vars">$sString</span><span>, </span><span class="vars">$aWords</span><span>) { </span></span>
- if (!is_array ($aWords) || emptyempty ($aWords) || !is_string ($sString)) {
- return false;
- }
- $sWords = implode ('|', $aWords );
- return preg_replace ('@b('.$sWords .')b@si', '$1', $sString );
- }
[Code] Get your Feedburner user
-
<span><span class="keyword">function</span><span> get_average_readers(</span><span class="vars">$feed_id</span><span>,</span><span class="vars">$interval</span><span> = 7){ </span></span>
- $today = date('Y-m-d', strtotime("now"));
- $ago = date('Y-m-d', strtotime("-".$interval." days"));
- $feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_URL, $feed_url);
- $data = curl_exec($ch);
- curl_close($ch);
- $xml = new SimpleXMLElement($data);
- $fb = $xml->feed->entry['circulation'];
- $nb = 0;
- foreach($xml->feed->children() as $circ){
- $nb += $circ['circulation'];
- }
- return round($nb/$interval);
- }
[代码] 自动生成密码
-
<span><span class="keyword">function</span><span> generatePassword(</span><span class="vars">$length</span><span>=9, </span><span class="vars">$strength</span><span>=0) { </span></span>
- $vowels = 'aeuy';
- $consonants = 'bdghjmnpqrstvz';
- if ($strength >= 1) {
- $consonants .= 'BDGHJLMNPQRSTVWXZ';
- }
- if ($strength >= 2) {
- $vowels .= "AEUY";
- }
- if ($strength >= 4) {
- $consonants .= '23456789';
- }
- if ($strength >= 8 ) {
- $vowels .= '@#$%';
- }
- $password = '';
- $alt = time() % 2;
- for ($i = 0; $i $length; $i++) {
- if ($alt == 1) {
- $password .= $consonants[(rand() % strlen($consonants))];
- $alt = 0;
- } else {
- $password .= $vowels[(rand() % strlen($vowels))];
- $alt = 1;
- }
- }
- return $password;
- }
[代码] 压缩多个CSS文件
-
<span><span>header(</span><span class="string">'Content-type: text/css'</span><span>); </span></span>
- ob_start("compress");
- function compress($buffer) {
- /* remove comments */
- $buffer = preg_replace('!/*[^*]**+([^/][^*]**+)*/!', '', $buffer);
- /* remove tabs, spaces, newlines, etc. */
- $buffer = str_replace(array("rn", "r", "n", "t", ' ', ' ', ' '), '', $buffer);
- return $buffer;
- }
- /* your css files */
- include('master.css');
- include('typography.css');
- include('grid.css');
- include('print.css');
- include('handheld.css');
- ob_end_flush();
[代码] 获取短网址
-
<span><span class="keyword">function</span><span> getTinyUrl(</span><span class="vars">$url</span><span>) { </span></span>
- return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
- }
[代码] 根据生日计算年龄
-
<span><span class="keyword">function</span><span> age(</span><span class="vars">$date</span><span>){ </span></span>
- $year_diff = '';
- $time = strtotime($date);
- if(FALSE === $time){
- return '';
- }
- $date = date('Y-m-d', $time);
- list($year,$month,$day) = explode("-",$date);
- $year_diff = date("Y") – $year;
- $month_diff = date("m") – $month;
- $day_diff = date("d") – $day;
- if ($day_diff $month_diff $year_diff–;
- return $year_diff;
- }
[代码] 计算执行时间
-
<span><span class="comment">//Create a variable for start time </span><span> </span></span>
- $time_start = microtime(true);
- // Place your PHP/HTML/JavaScript/CSS/Etc. Here
- //Create a variable for end time
- $time_end = microtime(true);
- //Subtract the two times to get seconds
- $time = $time_end - $time_start;
- echo 'Script took '.$time.' seconds to execute';
[代码] PHP的维护模式
-
<span><span class="keyword">function</span><span> maintenance(</span><span class="vars">$mode</span><span> = FALSE){ </span></span>
- if($mode){
- if(basename($_SERVER['SCRIPT_FILENAME']) != 'maintenance.php'){
- header("Location: http://example.com/maintenance.php");
- exit;
- }
- }else{
- if(basename($_SERVER['SCRIPT_FILENAME']) == 'maintenance.php'){
- header("Location: http://example.com/");
- exit;
- }
- }
- }
[代码] 阻止CSS样式被缓存
-
<span><span><link span=""> <span class="string">"/stylesheet.css?<!--?php echo time(); ?-->"</span><span> rel=</span><span class="string">"stylesheet"</span><span> type=</span><span class="string">"text/css"</span><span> /&glt; </span> href=</span></span>
[代码] 为数字增加 stndrd 等
-
<span><span class="keyword">function</span><span> make_ranked(</span><span class="vars">$rank</span><span>) { </span></span>
- $last = substr( $rank, -1 );
- $seclast = substr( $rank, -2, -1 );
- if( $last > 3 || $last == 0 ) $ext = 'th';
- else if( $last == 3 ) $ext = 'rd';
- else if( $last == 2 ) $ext = 'nd';
- else $ext = 'st';
- if( $last == 1 && $seclast == 1) $ext = 'th';
- if( $last == 2 && $seclast == 1) $ext = 'th';
- if( $last == 3 && $seclast == 1) $ext = 'th';
- return $rank.$ext;
- }
href=

译者 | 李睿审校 | 孙淑娟Web Speech API是一种Web技术,允许用户将语音数据合并到应用程序中。它可以通过浏览器将语音转换为文本,反之亦然。Web Speech API于2012年由W3C社区引入。而在十年之后,这个API仍在开发中,这是因为浏览器兼容性有限。该API既支持短时输入片段,例如一个口头命令,也支持长时连续的输入。广泛的听写能力使它非常适合与Applause应用程序集成,而简短的输入很适合语言翻译。语音识别对可访问性产生了巨大的影响。残疾用户可以使用语音更轻松地浏览

docker部署javaweb系统1.在root目录下创建一个路径test/appmkdirtest&&cdtest&&mkdirapp&&cdapp2.将apache-tomcat-7.0.29.tar.gz及jdk-7u25-linux-x64.tar.gz拷贝到app目录下3.解压两个tar.gz文件tar-zxvfapache-tomcat-7.0.29.tar.gztar-zxvfjdk-7u25-linux-x64.tar.gz4.对解

web端指的是电脑端的网页版。在网页设计中我们称web为网页,它表现为三种形式,分别是超文本(hypertext)、超媒体(hypermedia)和超文本传输协议(HTTP)。

区别:1、前端指的是用户可见的界面,后端是指用户看不见的东西,考虑的是底层业务逻辑的实现,平台的稳定性与性能等。2、前端开发用到的技术包括html5、css3、js、jquery、Bootstrap、Node.js、Vue等;而后端开发用到的是java、php、Http协议等服务器技术。3、从应用范围来看,前端开发不仅被常人所知,且应用场景也要比后端广泛的太多太多。

web前端打包工具有:1、Webpack,是一个模块化管理工具和打包工具可以将不同模块的文件打包整合在一起,并且保证它们之间的引用正确,执行有序;2、Grunt,一个前端打包构建工具;3、Gulp,用代码方式来写打包脚本;4、Rollup,ES6模块化打包工具;5、Parcel,一款速度极快、零配置的web应用程序打包器;6、equireJS,是一个JS文件和模块加载器。

怎么解决高并发大流量问题?下面本篇文章就来给大家分享下高并发大流量web解决思路及方案,希望对大家有所帮助!

和它本身的轻便一样,Bottle库的使用也十分简单。相信在看到本文前,读者对python也已经有了简单的了解。那么究竟何种神秘的操作,才能用百行代码完成一个服务器的功能?让我们拭目以待。1. Bottle库安装1)使用pip安装2)下载Bottle文件https://github.com/bottlepy/bottle/blob/master/bottle.py2.“HelloWorld!”所谓万事功成先HelloWorld,从这个简单的示例中,了解Bottle的基本机制。先上代码:首先我们从b

译者 | 李睿审校 | 孙淑娟Python Web应用程序长期以来一直遵循Web服务器网关接口(WSGI)标准,该标准描述了它们如何与Web服务器通信。WSGI最初于2003年推出,并于2010年更新,仅依赖于Python2.2版本中原生可用的、易于实现的功能。因此, WSGI迅速融入了所有主要的Python Web框架,并成为Python Web开发的基石。快进到2022年。Python2已经过时,Python现在具有处理网络调用等异步操作的原生语法。WSGI和其他默认假定同步行为的标准无法


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
