緊急求教PHP版本問題,12:10了我還沒有吃飯呢,各位幫忙!!
各位好,我在程式中用到了websocket功能,程式本機調試沒有報錯,但是傳到服務就報錯了,在網上找了下,說是PHP版一本http://s.yanghao.org/program/viewdetail.php?i=140457
我機器上的PHP版本是5.4的,伺服器上的是5.2的,請問PHP5.2中有沒有方便取代php5.3的命名空間功能,非常急!
require("lib/SplClassLoader.php");
$classLoader = new SplClassLoader("WebSocket","/lib");
$classLoader->register();
$server = new \WebSocket\Server("124.172.243.71", 8000, false);//這裡報錯
報錯的內容如下
Unexpected character in input: '\' (ASCII=92) state=1 in
版本
------解決方案--------------------
手冊上的一段回複
--------------------------------------------------
a dot schaffhirt at sedna-soft dot de02-Feb-2010 06:24
Just in case you wonder what the practical use of the namespace keyword is...
It can explicitly refer to classes from the current namespace regardless of possibly "use"d classes with the same name from other namespaces. However, this does not apply for functions.
Example:
namespace foo;
class Xyz {}
function abc () {}
?>
namespace bar;
class Xyz {}
function abc () {}
?>
namespace bar;
use foo
------解決方案--------------------
Xyz;
use foo
------解決方案--------------------
abc;
new Xyz(); // instantiates \foo\Xyz
new namespace
------解決方案--------------------
Xyz(); // instantiates \bar\Xyz
abc(); // invokes \bar\abc regardless of the second use statement
------解決方案--------------------
foo
------解決方案--------------------
abc(); // it has to be invoked using the fully qualified name
?>
(Sorry, I had to use "
------解決方案--------------------
" instead of "\", as it was always discarded in the preview, except within a comment.)
Hope, this can save someone from some trouble.
Best regards.
----------------------------------------
------解決方案--------------------
PHP5.2中沒有命名空間
你可以刪去有關“命名空間”的聲明部分
退化成普通的類和函數