紧急求教PHP版本有关问题,12:10了小弟我还没有吃饭呢,各位帮忙!
程序员文章站
2024-02-14 22:28:22
...
紧急求教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
各位好,我在程序中用到了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中没有命名空间
你可以删去有关“命名空间”的声明部分
退化成普通的类和函数
------解决方案--------------------
手册上的一段回复
--------------------------------------------------
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中没有命名空间
你可以删去有关“命名空间”的声明部分
退化成普通的类和函数
相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
上一篇: php写的AES加密解密类分享
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论