Unexpected character in input: '\' (ASCII=92) state=1

前端 未结 7 1751
长情又很酷
长情又很酷 2020-11-27 20:59

My client says he is getting this error using my script:

Warning: Unexpected character in input: \'\\\' (ASCII=92) state=1 in /path/to//header.php  on line 3         


        
相关标签:
7条回答
  • 2020-11-27 21:48

    Like other users say: use of namespaces are only valid for PHP versions greater than 5.3.0 so my solution for be able to include an optional use of a library using namespaces is to check the php version and use the eval() function to avoid that lower versions of PHP shoot an error, even on compilation time.

    Something like this:

    if ( phpversion() > '5.3.0' ){
        include_once('/path/to/Library.php'); 
        eval("Library\Foo::bar();"); 
    }
    
    0 讨论(0)
提交回复
热议问题