比如
$('#moveImage').bind('dblclick',function(){
window.location.href='{APP_PATH}index.php?m=special&c=index&a=special&siteid={$siteid}';
})
中的要写大括号标签,这么写肯定不行,要被解析错误的
但是要转义,试了一下也不行
如
$('#moveImage').bind('dblclick',function(){
window.location.href='\{APP_PATH\}index.php?m=special&c=index&a=special&siteid=\{$siteid\}';
})
那么问题来了,难道js中真的没有办法写入phpcms的标签符号吗,我估计这么多年了,我是第一个关注这种问题的,因为全论坛没有这方面的帖子.
回复讨论(解决方案)
应该是你写的不符合规范,否则就不可能只有你会遇到问题
1、APP_PATH 是什么?
如果是常量,那么你这样写在串中是错误的
如果不是常量,则一定有替换字符串为值的地方。那么该不该有大括号括起就是个问题了。即替换时是否会将大括号一起替换掉
这要看看做这事的代码了
2、在 js 中,除非有特殊需要是不必书写而外的路径的,如果写了则必须是绝对路径,否则就会被解释为子目录了
而你的 APP_PATH 显然是项目目录
3、你可以在浏览器中查看网页源文件,看看这部分变成什么了
不好意思刚睡醒脑子有点不清醒不太理解你的意思。
PHPCMS的模板引擎比较简单高效,也就是说只要花括号开始闭合都在同一行内且中间没有空格(loop、for、if、pc、php以及调用函数和允许出现空格 ),那么都会被模板引擎匹配到(常量、变量、自增自减等)。
详细的可以看模板引擎phpcms/libs/classes/template_cache.class.php中template_parse()方法。
然后看你最后一句,我暂且理解为在模板文件中script里调用模板标签,可以准确的告诉你是可以的,因为在模板引擎中,并没有对标签调用位置进行判断。
<script type="text/javascript">alert({APP_PATH});</script>
会弹出站点地址
所以,只要是在模板文件中,绝对可以在script中调用模板标签,反之,如果要在script中输出"{APP_PATH}",貌似只能通过加转义实现。
当然如果任性地在js文件中调用那就.......2333333333333333
<script type="text/javascript">alert("{APP_PATH}");</script>
行不行的?
<script type="text/javascript">alert("{APP_PATH}");</script>
这样能运行么
<script type="text/javascript">alert("{APP_PATH}");</script>
这样能运行么
那个楼主在PHPCMS论坛提问了然后就放弃这边结贴了,个西八= =。回复楼上,可以的~!!!
var path='{APP_PATH}';
$('#moveImage').bind('dblclick',function(){
window.location.href=path+'index.php?m=special&c=index&a=special&siteid={$siteid}';
})
呵呵
随便看看,偶不说话
<script type="text/javascript">alert("{APP_PATH}");</script>
这样能运行么
那个楼主在PHPCMS论坛提问了然后就放弃这边结贴了,个西八= =。回复楼上,可以的~!!!
想要得分很简单,你只要解决这个问题就行,又想得分,又不想解决问题,你回家问问你妈,有这好事吗

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


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

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

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

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
