Table of Contents
前沿:
正则表达式测试工具
MD5加密工具
SHA1加密工具:
URL转码和解码工具:
ASCII与字符之间的转换工具:
Home php教程 php手册 用PHP自己编写的站长工具箱

用PHP自己编写的站长工具箱

Jun 06, 2016 pm 07:53 PM
php work toolbox Own

前沿: 看到站长之家的站长工具很强大,所以也想自己试着实现一些其中的功能,由于本人只具有初阶的php技术,所以便用php一些函数实现了部分功能。 主要功能包括:正则表达式测试工具,MD5和SHA1加密工具,URL编码和解码工具,ASCII与字符之间的转换工具。

前沿:

看到站长之家的站长工具很强大,所以也想自己试着实现一些其中的功能,由于本人只具有初阶的php技术,所以便用php一些函数实现了部分功能。

主要功能包括:正则表达式测试工具,MD5和SHA1加密工具,URL编码和解码工具,ASCII与字符之间的转换工具。

演示地址:http://zhanzhanggongju.duapp.com/

正则表达式测试工具

演示地址:http://zhanzhanggongju.duapp.com/fun/zengze.php

原理:

通过表单获取正则规则和匹配的字符串,然后通过preg_match_all()函数,进行正则,然后用implode函数将获得的数组转化为字符串,再输出。

代码:

<div class="big">
<div class="welcome">正则表达式测试工具</div>
<div class="menu">
<form action="#" target="_self" method="post">
<p class="input">正 则 规 则 :<input type="text" name="mode"></p>

<p class="input">匹配字符串:<input type="text" name="str"></p>

<input type="submit" name="sub" value="匹配" class="button">
</form>
<p> </p>
<?php if(@$_POST[sub]){
	$mode="/".@$_POST[mode]."/";
	$str=@$_POST[str];
	echo "<p class=\"input\">匹配规则是:$mode";
	echo "<p class='\"input\"'>您输入的字符串是:$str</p>";
	if(preg_match_all($mode,$str,$arr)){
		echo "<p class='\"input\"'>匹配成功,匹配结果是:";
		echo "<font color='\"#FF0000\"'>".implode(" ",$arr[0])."</font></p>";
	}else{
      echo "<p class='\"input\"'>匹配失败,请检查正则或匹配字符串</p>";
	}
}
?>
</div>
<?php include("../footer.php");
?>
</div>

Copy after login

MD5加密工具

演示地址:http://zhanzhanggongju.duapp.com/fun/md5.php

原理:通过表单,获取需要加密的内容,然后当选择32位小写时,直接通过md5()函数进行加密;当选择32位大写的时候,把md5()加密以后的内容,在通过strtoupper()函数,将所有小写字母转化为大写;当选择16位的时候,通过substr(“str”,8,16)函数,将加密以后的内容进行截取,截取的规则是,从第8个字符开始,连续截取16个字符。

代码:

<div class="big">
<div class="welcome">md5算法是一种不可逆的加密算法</div>
<div class="menu">
<form action="#" target="_self" method="post">
<p class="input">加密内容:<input type="text" name="str"></p>
<p class="input"><input type="radio" name="encode" value="32xiao" checked>32位(小)    <input type="radio" name="encode" value="32da">32位(大)</p>
<p class="input"><input type="radio" name="encode" value="16xiao">16位(小)  
<input type="radio" name="encode" value="16da">16位(大)</p>
<input type="submit" name="sub" value="进行加密" class="button">
</form>
<?php if(@$_POST[sub]){
	$str=@$_POST[str];
	echo "<p class=\"input\">您要加密的内容为:".$str."";
	if(@$_POST[encode]=="32xiao"){
		 echo "<p class='\"input\"'>您选选择的32位小的加密算法</p>";
	     $result=md5($str);
	}else if(@$_POST[encode]=="32da"){
		echo "<p class='\"input\"'>您选选择的32位大的加密算法</p>";
		 $result=strtoupper(md5($str,false));
	}else if(@$_POST[encode]=="16xiao"){
		echo "<p class='\"input\"'>您选选16位小的加密算法</p>";
		$result=substr(md5("$str"),8,16);
	}else if(@$_POST[encode]=="16da"){
		echo "<p class='\"input\"'>您选选16位大的加密算法</p>";
		$result=strtoupper(substr(md5("$str"),8,16));
	}
	echo "<p class='\"input\"'>加密结果为:"."<font color='\"#FF0000\"'>".$result."</font></p>";
}
?>
</div>
<?php include("../footer.php");
?>
</div>
Copy after login

SHA1加密工具:

演示地址:http://zhanzhanggongju.duapp.com/fun/sha1.php

原理:通过表单获取加密内容,然后当选择40位SHA1小写 时,直接使用sha1()函数进行加密即可;当选择40位SHA1大写的时候,对加密以后的内容再使用strtoupper()函数,进行大小写转换。

代码:

<div class="big">
<div class="welcome">SHA1算法是一种不可逆的加密算法</div>
<div class="menu">
<form action="#" target="_self" method="post">
<p class="input">加密内容:<input type="text" name="str"></p>
<p class="input"><input type="radio" name="encode" value="xiao" checked>40位SHA1小写   <input type="radio" name="encode" value="da">40位SHA1大写</p>
<input type="submit" name="sub" value="进行加密" class="button">
</form>
<?php if(@$_POST[sub]){
	$str=@$_POST[str];
	echo "<p class=\"input\">您要加密的内容为:".$str."";
	if(@$_POST[encode]=="xiao"){
		 echo "<p class='\"input\"'>您选择了40位SHA1小的加密算法</p>";
	     $result=sha1($str);
	}else if(@$_POST[encode]=="da"){
		echo "<p class='\"input\"'>您选择了40位SHA1大的加密算法</p>";
		$result=strtoupper(sha1($str,false));
	}
		echo "<p class='\"input\"'>加密结果为:"."<font color='\"#FF0000\"'>".$result."</font></p>";
}
?>
</div>
<?php include("../footer.php");
?>
</div>
Copy after login

URL转码和解码工具:

演示地址:http://zhanzhanggongju.duapp.com/fun/urlen.php

原理:

通过表单获取需要转码(或解码)内容,然后通过urlencode()函数(或urldecode()函数)进行操作。

url转码的代码:

<div class="big">
<div class="welcome">将非数字字母转换为url编码的方法</div>
<div class="menu">
<form action="#" target="_self" method="post">
<p class="input">编码内容:<input type="text" name="str"></p>
<input type="submit" name="sub" value="进行编码" class="button">
</form>
<?php if(@$_POST[sub]){
	$str=@$_POST[str];
	echo "<p class=\"input\">您要编码的内容为:".$str."";
	echo  "<p class='\"input\"'>url编码结果:"."<font color='\"#FF0000\"'>".urlencode($str)."</font></p>";
}
?>
</div>
<?php include("../footer.php");
?>
</div>
Copy after login

ASCII与字符之间的转换工具:

演示地址:http://zhanzhanggongju.duapp.com/fun/asciito.php

原理:

通过表单获取需要转换内容,然后通过函数chr()实现ASCII码到字符的转换,通过函数ord()实现字符到ASCII码之间的转换。

由于只有3~126之间的ASCII码,才能进行打印在显示器上,所以该工具只能显示这部分的ASCII码。

ASCII转到字符的代码:

<div class="big">
<div class="welcome">本工具只支持33~126之间的ASCII码查询</div>
<div class="menu">
<form action="#" target="_self" method="post">
<p class="input">ASCII码:<input type="text" name="str"></p>
<input type="submit" name="sub" value="进行转换" class="button">
</form>
<?php if(@$_POST[sub]){
	$str=@$_POST[str];
	echo "<p class=\"input\">您要转码的字符为:".$str."";
	echo  "<p class='\"input\"'>ASCII码对应的字符为:"."<font color='\"#FF0000\"'>".chr($str)."</font></p>";
}
?>
</div>
<?php include("../footer.php");
?>
</div>
Copy after login

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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Top 10 Free Virtual Currency Exchanges Rankings The latest top ten virtual currency APP trading platforms Top 10 Free Virtual Currency Exchanges Rankings The latest top ten virtual currency APP trading platforms Mar 11, 2025 am 10:18 AM

The top ten free virtual currency exchanges are ranked: 1. OKX; 2. Binance; 3. Gate.io; 4. Huobi Global; 5. Kraken; 6. Coinbase; 7. KuCoin; 8. Crypto.com; 9. MEXC Global; 10. Bitfinex. These platforms each have their own advantages.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles