doujiao1948
2013-11-26 17:50 阅读 225
已采纳

使用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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dsv38843 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.

    点赞 4 评论 复制链接分享
  • dongxiangxie8181 dongxiangxie8181 2015-12-12 02:00

    in dreamweaver cc 2015, your code still alert in the info bar as an error.

    dreamweaver use a PHP_KnowledgeEngine.dll (in it's configration folder), it seems this engine is using some source code fron zend engine, but it still cannot correcttly handle this situation.

    点赞 5 评论 复制链接分享

相关推荐