doujiao1948
2013-11-26 17:50
浏览 239
已采纳

使用PHP 5.4的Dreamweaver CS5代码提示和语法错误

I have done some research but have not found something that fits my scenario exactly. I am using Dreamweaver CS5 with PHP files and Dreamweaver alerts me that there is an error in my code with this line:

if(explode("_","some_variable")[0]=="some"){

If I remove the brackets [ ] then the error message goes away making the line be

if(explode("_","some_variable")=="some"){ //never true obviously

I know that I could assign the exploded array to a variable and then call the first value of that variable to remove this code but I was trying to find a solution to be able to write a little more shorthand code.

I found that this method of calling an index is supported from PHP version 5.4 from the answer here: https://stackoverflow.com/a/19408331/1707323 but Dreamweaver still throws error alert. I was able to find out that Dreamweaver CS5 supports code hinting and syntax for PHP version 5.2.

So the main question is: How can I add more support to Dreamweaver CS5 code hinting and syntax checker OR is there a way to ignore certain syntax errors while preserving the rest of the syntax checker?

I know that I could change the line to

if($string = explode("_",$key) && $string[0]=="understand"){

Or I could write a custom function such as the referred answer above suggests, but why write extra code just to satisfy an outdated syntax checker when there might be a way to update the syntax checker.

Note: I am not looking for any answers that involves updating to a newer version of Dreamweaver such as CS5.5 or CS6 as I already have CS5 and do not want to dish out money just for this reason.

图片转代码服务由CSDN问答提供 功能建议

我做了一些研究,但没有找到适合我的方案的东西。 我正在使用Dreamweaver CS5和PHP文件,Dreamweaver警告我,我的代码中有一行错误:

  if(explode(“_”,“some_variable”)  [0] ==“some”){
   
 
 

如果我删除括号 [ ] ,那么 错误信息消失使得该行

  if(explode(“_”,“some_variable”)==“some”){//从来没有真正显然
   
 
 

我知道我可以将爆炸数组分配给变量,然后调用该变量的第一个值来删除此代码,但我试图找到一个解决方案,以便能够 写一些简写代码。

我发现这个调用索引的方法是从PHP 5.4版本支持的答案:https://stackoverflow.com/a/19408331/1707323 但Dreamweaver仍然会抛出错误警报。 我能够发现Dreamweaver CS5支持PHP 5.2版的代码提示和语法。

所以主要问题是:如何为Dreamweaver CS5代码提示和语法检查添加更多支持 或者有没有办法忽略某些语法错误,同时保留其余的语法检查器?

我知道我可以将行更改为

   if($ string = explode(“_”,$ key)&& $ string [0] ==“理解”){
   
 
 

或者我可以编写一个自定义函数,例如上面提到的参考答案,但是为什么在可能有更新语法检查器的方法时,为了满足过时的语法检查程序而编写额外的代码。

注意:我不是在寻找任何涉及更新到Dreamweaver的新版本的答案,例如CS5.5或CS6,因为我已经拥有CS5并且不想因为这个原因而出钱。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dsv38843 2014-01-29 15:52
    已采纳

    The short answer is you can't extend code syntax for CS5. Adobe doesn't support older versions of Dreamweaver and there will not be a patch for it. They want you to upgrade to the latest (subscription-based) version instead.

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题