緊急求教PHP版本有關問題,12:10了小弟我還沒有吃飯呢,各位幫忙!

來源:互聯網
上載者:User
緊急求教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中沒有命名空間
你可以刪去有關“命名空間”的聲明部分
退化成普通的類和函數
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.