当前位置: 首页 > 编程文章 >

支持IE和Firefox的JS代码美化加亮源码

支持IE和Firefox的JS代码美化加亮源码

作者:陆景时间:2026-08-19 17:34:38浏览:615

提供一段经过压缩处理的JavaScript代码,用于实现网页中JS代码的美化与语法加亮效果。该方案已在Internet Explorer及Firefox浏览器中进行过测试验证,确保跨浏览器的兼容性表现。

本文目录展开

JS代码美化效果说明

笔者已在Internet Explorer与Firefox浏览器中实测了JavaScript代码的高亮显示效果。测试过程中引用了一段他人提供的、经过压缩处理的代码作为示例,由于篇幅限制,对部分内容进行了删减。若发现任何错误,恳请使用者提供测试用的代码以便反馈。


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML xmlns:v="urn:schemas-microsoft-com:vml"> <HEAD> <TITLE> 本站 www.jb51.net </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <link rel="Shortcut Icon" href="shell32.dll,20"> <STYLE> #oTxt{     color:#333333;     background-color:#f0f0f0;     font-family:Courier New;     font-size:12px;     margin:0;     line-height:13px;     border-left:none;     overflow:scroll; } #oResult{     color:#333333;     background-color:#f0f0f0;     font-family: Courier New;     font-size:12px;     margin:0;     line-height:13px;     border-left:none;     overflow:scroll;     height:164px; } </STYLE> </HEAD> <BODY>  <textarea id=oTxt wrap=off style="border:dashed 1px gray; border-right:none; border-bottom:none; width:400;height:164px;padding:2px;" onkeyup="_highlight()"> //<!-- // test comment //    s = s.replace(/\/\//g, ''); /*/     'this is a block'     'http://test.com'     'comment !!' //*/ //*/     'string2'     'http://test.com'     "string1/*" //*/ /*/     'this is a block'     'http://test.com'     "comment !!" /*/     "string1: start a comment /* "     'http://test.com'     'string2: end a comment */ ' //*/ /****************************\ * code highlight             * *     necrocoder 2006.05.11  * \****************************/ var sss = kkkk.innerHTML+"\r\n"; for(var i=0;i<5;i++) sss += kkkk.innerHTML+"\r\n"+"\r\n"; var tm = (new Date()).getTime(); sss = sss.syntaxed(); var dtm = (new Date()).getTime() - tm; aaa.innerHTML = sss; //aaaa.innerText = sss; document.write('highlighted in '+dtm+'ms.'); /*  * Examples  */ Array.prototype.indexOf=function(o){for(var i=0;i<this.length;i++){if(this[i]==o)return i;} return-1;};Array.prototype.lastIndexOf=function(o){for(var i=this.length-1;i>=0;i--){if(this[i]==o)return i;}return-1;};Array.prototype.contains=function(o){return this.indexOf(o)!= -1;};Array.prototype.copy=function(o){return this.concat();};Array.prototype.insertAt=function(o,i){this.splice(i,0,o);};Array.prototype.insertBefore=function(o,o2){var i=this.indexOf(o2);if(i== -1)this.push(o);else this.splice(i,0,o);};Array.prototype.removeAt=function(i){this.splice(i,1);};Array.prototype.remove=function(o){var i=this.indexOf(o);if(i!= -1)this.splice(i,1);};String.prototype.trim=function(){return this.replace(/(^\s+)|\s+$/g,"");};Function.READ=1;Function.WRITE=2;Function.READ_WRITE=3;Function.prototype.addProperty=function(sName,nReadWrite){nReadWrite=nReadWrite||Function.READ_WRITE;var capitalized=sName.charAt(0).toUpperCase()+sName.substr(1);if(nReadWrite&Function.READ) this.prototype["get"+capitalized]=new Function("","return this._"+sName+";");if(nReadWrite&Function.WRITE)   this.prototype["set"+capitalized]=new Function(sName,"this._"+sName+" = "+sName+";");};function BiObject(){this._hashCode=BiObject._hashCodePrefix+Math.round(Math.random()*1000)+BiObject._hashCodePrefix+BiObject._hashCodeCounter++;} _p=BiObject.prototype=new Object;_p._className="BiObject";_p._disposed=false;_p._id=null;BiObject._hashCodeCounter=1;BiObject._hashCodePrefix="hc";BiObject.toHashCode=function(o){if(o._hashCode!=null) return o._hashCode;return o._hashCode=BiObject._hashCodePrefix+Math.round(Math.random()*1000)+BiObject._hashCodePrefix+BiObject._hashCodeCounter++;};BiObject.prototype.getDisposed=function(){return this._disposed;};BiObject.prototype.getId=function(){return this._id;};BiObject.prototype.setId=function(v){this._id=v;};BiObject.prototype.getUserData=function(){return this._userData;};BiObject.prototype.setUserData=function(v){this._userData=v;};_p.toHashCode=function(){return BiObject.toHashCode(this);};_p.dispose=function(){this._disposed=true;delete this._userData;};_p.toString=function(){if(this._className) return"[object "+this._className+"]";return"[object Object]";};_p.getProperty=function(sPropertyName){var getterName="get"+sPropertyName.charAt(0).toUpperCase()+sPropertyName.substr(1);if(typeof this[getterName]=="function") return this[getterName]();throw new Error("No such property, "+sPropertyName);};_p.setProperty=function(sPropertyName,oValue){var setterName="set"+sPropertyName.charAt(0).toUpperCase()+sPropertyName.substr(1);if(typeof this[setterName]=="function") this[setterName](oValue);else throw new Error("No such property, "+sPropertyName);};_p.setAttribute=function(sName,sValue,oParser) {var v;if(sValue=="true") v=true;else if(sValue=="false") v=false;else if(parseFloat(sValue)==sValue) v=parseFloat(sValue);else v=sValue;this.setProperty(sName,v);};_p.getAttribute=function(sName) {return String(this.getProperty(sName));};_p.addXmlNode=function(oNode,oParser) {if(oNode.nodeType==1) oParser.fromNode(oNode);};if(typeof BiObject=="undefined") BiObject=new Function;function BiBrowserCheck(){if(BiBrowserCheck._singleton) return BiBrowserCheck._singleton;var ua=navigator.userAgent;this._ie= /msie/i.test(ua);this._moz=navigator.product=="Gecko";this._platform=navigator.platform;if(this._moz) {/rv\:([^\);]+)(\)|;)/.test(ua);this._version=RegExp.$1;this._ie55=false;this._ie6=false;} else {/MSIE\s+([^\);]+)(\)|;)/.test(ua);this._version=RegExp.$1;this._ie55= /msie 5\.5/i.test(ua);this._ie6= /msie 6/i.test(ua);} BiBrowserCheck._singleton=this;} BiBrowserCheck.prototype=new BiObject;BiBrowserCheck.prototype.getIe=function() {return this._ie;};BiBrowserCheck.prototype.getIe55=function() {return    this._ie55;};BiBrowserCheck.prototype.getIe6=function() {return this._ie6;};BiBrowserCheck.prototype.getMoz=function() {return this._moz;};BiBrowserCheck.prototype.getVersion=function() {return this._version;};BiBrowserCheck.prototype.getPlatform=function() {return this._platform;};var _br=new BiBrowserCheck;BiBrowserCheck.ie=_br.getIe();BiBrowserCheck.ie55=_br.getIe55();BiBrowserCheck.ie6=_br.getIe6();BiBrowserCheck.moz=_br.getMoz();BiBrowserCheck.version=_br.getVersion();BiBrowserCheck.platform=_br.getPlatform();_br=null;function BiUri(sBase,sRel) {this._params={};if(sBase) {this.setHref(sBase);if(sRel) this._setRelative(sRel)}} _p=BiUri.prototype=new BiObject;_p._className="BiUri";_p._scheme="";_p._userInfo="";_p._port="";_p._host="";_p._path="";_p._dirPath="";_p._fragment="";_p._query="";_p._hrefCache=null;BiUri.prototype.getScheme=function(){return this._scheme;};BiUri.prototype.getPath=function(){return this._path;};BiUri.prototype.getDirPath=function(){return this._dirPath;};BiUri.prototype.getHost=function(){return this._host;};BiUri.prototype.getPort=function(){return this._port;};BiUri.prototype.getFragment=function(){return this._fragment;};BiUri.prototype.getQuery=function(){return this._query;};BiUri.prototype.getUserInfo=function(){return this._userInfo;};BiUri.regExps={scheme:/^([^:]+)\:.+$/,user:/^([^@\/]+)@.+$/,host:/^([^:\/\?\#]+).*$/,port:/^:(\d+)/,path:/^([^\?#]*)/,dirPath:/^(.*\/)[^\/]*$/,fragment:/^[^#]*#(.*)$/,absUri:/^\w(\w|\d|\+|\-|\.)*:/i};_p.toString=function() {return this.getHref();};_p.setHref=function(s) {this._hrefCache=null;s=String(s);this._scheme="";this._userInfo="";this._host="";this._port=null;this._path="";this._dirPath="";this._query="";this._fragment="";this._params={};var err=new Error("Not a well formatted URI");var ok=BiUri.regExps.scheme.test(s);if(!ok)throw err;this._scheme=RegExp.$1;if(this._scheme=="mailto"||this._scheme=="news"||this._scheme=="view-source") s=s.substring(this._scheme.length+1);else s=s.substring(this._scheme.length+3);ok=BiUri.regExps.user.test(s);if(ok) {this._userInfo=RegExp.$1;s=s.substring(this._userInfo.length+1);} if(this._scheme!="file"||s.charAt(0)!="/") {ok=BiUri.regExps.host.test(s);if(!ok) throw err;this._host=RegExp.$1;s=s.substring(this._host.length);} ok=BiUri.regExps.port.test(s);if(ok) {this._port=Number(RegExp.$1);s=s.substring(RegExp.$1.length+1);} this._parsePathAndRest(s);};_p._parsePathAndRest=function(s) {var err=new Error("Not a well formatted URI");var ok=BiUri.regExps.path.test(s);if(!ok) throw err;this._path=RegExp.$1;s=s.substring(this._path.length);if(this._path==""&&(this._scheme=="file"||this._scheme=="http"||this._scheme=="https"||this._scheme=="ftp")) {this._path="/";} var segments=this._path.split("/");var sb=[];var j=0;for(var i=0;i<segments.length;i++) {if(segments[i]==".") continue;if(segments[i]=="..") {j--;delete sb[j];sb.length=j continue;} sb[j++]=segments[i];} this._path=sb.join("/");if(this._path.length>0) {ok=BiUri.regExps.dirPath.test(this._path);if(!ok) throw err;this._dirPath=RegExp.$1;} ok=BiUri.regExps.fragment.test(s);if(ok) {this._fragment=RegExp.$1;s=s.substring(0,s.length-this._fragment.length-1);this._fragment="#"+this._fragment.replace("#","%23");} this._query=s;s=s.substring(1);if(this._query!="") {var pairs=s.split(/\;|\&/);var parts;for(var i=0;i<pairs.length;i++) {parts=pairs[i].split("=");if(parts.length==2) this._params[parts[0]]=decodeURIComponent(parts[1]);else this._params[pairs[i]]=null;}}};_p._setRelative=function(s) {this._hrefCache=null;s=String(s);var isAbsolute=BiUri.regExps.absUri.test(s);if(isAbsolute) {this.setHref(s);return;} var dirPath=this._dirPath;this._path="";this._dirPath="";this._query="";this._fragment="";this._params={};if(s.charAt(0)=="/") {this._parsePathAndRest(s)} else this._parsePathAndRest(dirPath+s);};_p.getHref=function() {if(this._hrefCache!=null) return this._hrefCache;var s=this._scheme+(this._scheme=="mailto"||this._scheme=="news"||this._scheme=="view-source"?":":"://")+this._userInfo+(this._userInfo==""?"":"@")+this._host+(this._port!=null?":"+this._port:"")+this._path;var sb=[];for(var name in this._params) {if(this._params[name]!=null) sb.push(name+"="+encodeURIComponent(this._params[name]));else sb.push(name);} return this._hrefCache=s+this.getQuery()+this._fragment;};_p.getParam=function(sName) {return this._params[sName];};_p.setParam=function(sName,sValue) {this._hrefCache=null;return this._params[sName]=String(sValue);};_p.removeParam=function(sName) {this._hrefCache=null;delete this._params[sName];};_p.getQuery=function() {var sb=[];for(var name in this._params) {if(this._params[name]!=null) sb.push(name+"="+encodeURIComponent(this._params[name]));else sb.push(name);} return(sb.length>0?"?"+sb.join("&"):"");};function BiEvent(sType) {BiObject.call(this);this._type=sType;} _p=BiEvent.prototype=new BiObject;_p._className="BiEvent";_p._bubbles=false;_p._propagationStopped=true;_p._defaultPrevented=false;BiEvent.prototype.getType=function(){return this._type;};BiEvent.prototype.getTarget=function(){return this._target;};BiEvent.prototype.getCurrentTarget=function(){return this._currentTarget;};BiEvent.prototype.getBubbles=function(){return this._bubbles;};_p.initDispatch=function(){};_p.stopPropagation=function() {this._propagationStopped=true;};_p.preventDefault=function() {this._defaultPrevented=true;};_p.dispose=function() {this._target=null;this._currentTarget=null;};_p.getDefaultPrevented=function() {return this._defaultPrevented;};function BiMouseEvent(){};function BiKeyboardEvent(){};application=new BiApplication;application._coreScriptFiles_ie=["js/coreclasses.js","js/xmlrpc.js","js/guicomponents.js","js/gauge.ie.js","js/menu.ie.js","js/window.js","js/grids.js","js/databinding.js","js/chartingbase.js","js/charting.js","js/charting2.js","js/datetime.js"];application._coreScriptFiles_moz=["js/coreclasses.js","js/xmlrpc.js","js/guicomponents.js","js/menu.moz.js","js/window.js","js/grids.js","js/databinding.js","js/chartingbase.js","js/charting2.js","js/datetime.js"];if(BiBrowserCheck.ie) application._coreScriptFiles=application._coreScriptFiles_ie;else application._coreScriptFiles=application._coreScriptFiles_moz; //--> <&#47textarea> <SCRIPT LANGUAGE="JavaScript"> <!-- var tm_highlight = null; function _highlight() {     clearTimeout(tm_highlight);     tm_highlight = setTimeout('document.getElementById("oResult").innerHTML = ("<nobr>"+document.getElementById("oTxt").value.formatJS()+"</nobr>");', 1000); } //String.prototype.div = document.createElement('div'); String.prototype.toHtml = function () {     return this     .replace(/\&/g, '&')     .replace(/\</g, '<')     .replace(/\>/g, '>')     .replace(/\x20/g, ' ')     .replace(/(\r\n|\r|\n)/g, ''); }; String.prototype.formatJS = function () {     var s = this;     var index = 0, brch=0;     var keywords = ['abstract','boolean','break','byte','case','catch','char','class','const','continue','default','delete','do','double','else','extends','false','final','finally','float','for','function','goto','if','implements','import','in','instanceof','int','interface','long','native','new','null','package','private','protected','public','return','short','static','super','switch','synchronized','this','throw','throws','transient','true','try','typeof','var','void','while','with'];     var objects = ['Anchor','anchors','Applet','applets','Area','Array','arguments','Button','Checkbox','Date','document','FileUpload','Form','forms','Frame','frames','Function','Hidden','history','Image','images','Link','links','Area','location','Math','MimeType','mimeTypes','navigator','options','Password','Plugin','plugins','Radio','Reset','RegExp','Select','String','Submit','Text','Textarea','window'];     var specials = ['prototype','callee','caller','apply','call','encodeURIComponent','decodeURIComponent','parseInt','parseFloat','__defineGetter__','__defineSetter__'];     var blocks = [];     var indent = "", indent_fix="";     s=s     .replace(/\t/g, '    ')     .replace(/\r\n|\r/g, "\n")     .replace(/(\/\/[^\n]*(\n|$)|\/\*(\*(?!\/)|[^\*])*\*+\/|\"(\\\"|\\\\|[^\"\n])*\"|\'(\\\'|\\\\|[^\'\n])*\'|([=!\(\:\{\[\;]\s*)\/(\\.|[^\/\n])+\/[igm]*)/g,         function ($0)         {             var color = "#CCCCCC", ret = "'"; // comment             var kkk = $0;             if(kkk.charAt(0) == '"')                 color = "#FF00FF"; // double quote             else if(kkk.charAt(0) == "'")                 color = "#9900FF"; // single quote             else if(kkk.match(/^(?:[=!\(\:\{\[]\s*)(\/(\\.|[^\/\n])+\/[igm]*$)/))             {                 ret = kkk.replace(/^([=!\(\:\{\[]\s*)(\/(\\.|[^\/\n])+\/[igm]*$)/, "$1'");                 kkk = kkk.replace(/^([=!\(\:\{\[]\s*)(\/(\\.|[^\/\n])+\/[igm]*$)/, "$2");                 color = "#6666CC"; // regexp             }             blocks[blocks.length] = "<font color="+color+">"+kkk.toHtml()+"</font>";             return ret;         }) //    alert(blocks);s=s     .replace(/(\}?[\n ]*;[\n ]*)/g, function ($0,$1){return $1.replace(/[\n ]/g, '')+"\n";})     .replace(/\b(else)\b/g, "$1\n")     .replace(/\b((case|default)[^:]*\:)/g, "$1\n")     .replace(/(\{[\n ]*)((([A-Za-z\$\_][0-9A-Za-z\$\_]*|`)[\n ]*\:[\n ]*[^,\}]+,?)+)([\n ]*\})/g, function ($0,$1,$2,$3,$4,$5)         {             return $1+$2.replace(/[\n ]+/g, ' ').replace(/(([A-Za-z\$\_][0-9A-Za-z\$\_]*|`)\:[^,\}]+,?)/g, "$1\n")+$5;         })     .replace(/[\n ]*(\{|\};?)[\n ]*/g, function ($0, $1)         {             if($1.charAt(0) == '}') brch--;             var ss = "\n";             for(var i=0;i<brch;i++) ss += "    ";             if($1 == '{') brch++;             return ss+$1+"\n";         })     .replace(/[\n ]*\{[\n ]*\}/g, '{}')     .replace(/^[ ]*([^\{\}])/g, "$1")     .replace(/(\n\s*for\b[^\n]*\;\s*)\n/g, '$1')     .replace(/(\n\s*for\b[^\n]*\;\s*)\n/g, '$1')     .replace(/\n\s*(for|while|if|switch)\b[^\n]*; *\n/g, function ($0, $1)         {             var le = 0;             for(var i=0;i<$0.length;i++)                 if($0.charAt(i) == '(') le++; else if($0.charAt(i) == ')'){le--; if(le == 0)return $0.substr(0,i+1)+"\n"+$0.substr(i+1,$0.length);}         })     .replace(/(\n *)*(\n *)/g, "$2")     .replace(/(`\s*)\+(?=\s*`)/g, "$1\n+")     .replace(/( *)([^\n]*)\n/g, function ($0, space, text)         {             var ret = $0;             if(text.match(/^\{/))             {                 indent = space+"    ";                 indent_fix = "";             }             else if(text.match(/^\}/))             {                 indent = space;                 indent_fix = "";             }             else             {                 if(text.match(/^(case|default)\b/))                     ret = indent.substr(0,indent.length-4) + text;                 else                     ret = indent + indent_fix + text;                 if(text.match(/^(if|for|else|var|while)\b/) && !text.match(/\;\s*$/))                     indent_fix = "    ";                 else if(!text.match(/[^\;]\s*$/))                     indent_fix = "";                 if(text.charAt(0)=='+')                     ret = "    "+ret;                 ret += "\n";             }             return ret;         })     .replace(/\&/g, '&')     .replace(/\</g, '<')     .replace(/\>/g, '>')     .replace(/\x20/g, ' ')     .replace(eval('/\\b('+keywords.join('|')+')\\b/g'),'<font color=blue>$1</font>') // keywords     .replace(eval('/\\b('+objects.join('|')+')\\b/g'),'<font color=red>$1</font>') // objects     .replace(eval('/\\b('+specials.join('|')+')\\b/g'),'<font color=#0099CC>$1</font>') // objects     .replace(/\n/g, '')     .replace(/\'/g, function ($0){return blocks[index++];});     return s; } tm_highlight = setTimeout('document.getElementById("oResult").innerHTML = ("<nobr>"+document.getElementById("oTxt").value.formatJS()+"</nobr>");', 1); //--> </SCRIPT> <hr style="color:black;height:2px;">   </BODY> </HTML>

[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]

上一篇
PHP反射API插件系统架构示例

本文分享了利用 PHP 反射 API 构建插件系统的技术实例。通过反射机制,开发者可以动态分析类结构并实现松耦合的插件架构,为相关开发提供参考。

下一篇
在 CentOS 8/RHEL 8 上安装和使用 Cockpit的方法

Cockpit 是 CentOS 8 和 RHEL 8 默认的基于 Web 的服务器管理工具,提供图形界面以监控和管理 Linux 系统、网络、存储及容器。本文演示如何通过 DNF 安装 Cockpit,配置防火墙与 systemd 服务,并通过浏览器访问其 Web 控制台进行系统更新、网络接口配置(如网桥)及日志查看等日常运维操作。

相关文章

更多
解决IE、Firefox与Opera浏览器兼容性的常见陷阱

本文总结了在IE、Firefox和Opera等主流浏览器中开发JavaScript时遇到的典型兼容性问题。主要涵盖三种场景:一是通过脚本设置onload事件句柄时,Firefox下document.body.onload为undefined导致失效,推荐使用window.onload;二是浮动广告等布局代码中,Firefox遵循标准将滚动条归属document.documentElement而非body,需调整scrollTop获取方式;三是事件对象的使用差异,IE依赖全局window.event,而Firefox将event作为参数传递,需采用兼容写法统一处理。

2025.06.07 802
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,016
PHP与JavaScript及表单变量相互传递的实现方法

本文介绍PHP与JavaScript之间以及表单元素间变量传递的几种常见实现方式。主要涵盖从PHP向JS赋值、通过隐藏表单字段在JS与PHP间中转数据,以及利用PHP动态生成表单默认值等场景,提供对应的HTML与代码片段参考。

2025.10.11 995
JavaScript setAttribute 方法详解与浏览器兼容性处理

setAttribute用于动态设置HTML元素的属性值,但在不同浏览器中存在显著差异。Firefox支持标准的class属性设置,而IE内核浏览器需使用className;此外,IE不支持通过setAttribute设置onclick等事件属性或style对象属性,此时应改用点符号法直接赋值以确保跨浏览器兼容性。

2026.09.09 986
原生JS实现京东秒杀倒计时功能详解

本文介绍使用原生 JavaScript 实现移动端京东秒杀倒计时的具体方法。核心逻辑通过计算目标时间与当前时间的毫秒差值,结合 setInterval 定时器进行实时更新。文中详细解析了 Date 对象月份从 0 开始的特性、毫秒换算规则以及不足两位数字补零的处理方式,并提供了完整的 HTML 结构、SASS 样式及 JS 代码示例。

2025.06.13 985
在Golang中使用Goja引擎运行JavaScript代码

本文介绍如何在Golang中通过Goja库执行JavaScript代码。Goja实现了ES 5.1及大部分ES 6语法,可作为Chrome V8引擎的轻量级替代方案。文章演示了从安装依赖、创建虚拟机、加载脚本到将JS函数映射为Go函数并调用的完整流程,特别适用于需要生成Token等场景下的性能优化。

2025.01.30 982

专题推荐

更多
PHP 类与对象定义及继承

先看类声明、对象实例与属性访问。理解对象的创建和销毁后,再读继承、方法重载和关键字对照。已有代码遇到继承行为差异时,可进一步查看 final 方法与反射实例。

PHP 定时任务配置与运行

先确定任务运行间隔以及是否允许重叠。固定时间触发先看 Cron 案例,框架内和常驻服务再读对应示例。

Yii2 队列配置与常驻运行

先用一个最小任务跑通入队和消费,再检查 Web 与 Console 是否加载了相同的队列配置。确认命令能手动运行后再配置 Supervisor,最后验证进程重启时的处理情况。

PHP Session 过期时间设置方法

浏览器关闭、服务端回收和业务规定的闲置超时,可能在不同时间发生。对照配置项与应用层时间戳的做法,检查会话何时仍可读、何时应要求重新登录。

PHP URL 编码和解码方法

URL 路径片段和查询参数对空格的处理方式不同。先比较 urlencode 与 rawurlencode,再沿解码过程核对中文、加号和百分号,检查地址是否被重复编码或提前解码。

在线工具箱

更多
键码查询
键码查询

按下键盘按键时查看浏览器记录的键名和事件信息。

.env 配置检查
.env 配置检查

本地检查 .env 键值语法、引号、重复键及空值,预览解析结果,辅助排查 PHP 和 Laravel 环境配置。

进制转换
进制转换

转换二进制、十进制、十六进制等数值表示,辅助程序调试与进制学习。

HTML 标签安全清理
HTML 标签安全清理

清理 HTML 片段中的标签或危险内容,辅助整理待展示的文本。

文件 Base64 转换
文件 Base64 转换

把文件转为 Base64 文本,也可将编码内容还原为文件,方便接口传输与调试。