当前位置:首页 » 编程语言 » phpstrictstandards

phpstrictstandards

发布时间: 2022-08-10 12:22:55

A. php报警:Strict Standards: Only variables should be passed by reference in ......on line 641。

如果是这行的话,应该是因为end函数的原因。
end函数: mixed end
( array &$array
)
你可以看到end的参数是一个引用(reference),而你只能把一个变量的引用作为一个参数传给函数,而你直接把explode('.',$name)作为参数传给end函数,所以才有这个提示。
你可以这样修改,先定义一个变量,然后把这个变量传给end函数,这样应该可以取消这个提示:
$tmp_name=explode('.',$name);
$name = substr($name, 0, -strlen($ext)) . "_medium." . end($tmp_name);

B. 我安装ECMall后报PHP Strict Standards错误,请问如何解决

当你的网站出现
Strict Standards: Non-static method ECMall::startup() should not be called statically in /htdocs/ecmall/index.php on line 22
Deprecated: Assigning the return value of new by reference is deprecated in /htdocs/ecmall/eccore/controller/app.base.php on line141
Deprecated: Assigning the return value of new by reference is deprecated in /htdocs/ecmall/includes/ecapp.base.php on line 137
Strict Standards: Declaration of FrontendApp::jslang() should be compatible with ECBaseApp::jslang($lang) in /htdocs/ecmall/app/frontend.base.php on line 363
Strict Standards: Declaration of Message::display() should be compatible with BaseApp::display($n) in /htdocs/ecmall/eccore/controller/message.base.php on line 329
等类似错误提示的时候(PHP5.2.*版本的同样有这情况),可以考虑我们下面给出的解决方法:

1)问题分析:该错误是PHP环境配置的问题,并非程序问题;
2)找到php.ini 文件,将 error_reporting 的值改为:error_reporting = E_ALL & ~E_NOTICE
3)重启Apache或者IIS。
4)完毕

C. 安装 ecshop后报错 Strict standards: Only variables should be passed by reference in

http://localhost/upload/admin/index.php
进入后台清除下缓存就好了

D. 如何看待PHP Strict Standards错误

前天无意修改了php.ini关于错误输出的设置,今天测试一个CakePHP开发的项目时竟然发现多了几条错误提示,虽然不是致命的但也不能忽视。

错误的描述大概如下

Strict Standards: Redefining already defined constructor for class Object in D:\www\hosts\cake\ucake-libs\cake\libs\object.php on line 69

Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\object.php on line 94

Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\security.php on line 48

Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\inflector.php on line 65

Strict Standards: Assigning the return value of new by reference is deprecated in D:\www\hosts\cake\ucake-libs\cake\libs\configure.php on line 89

Strict Standards: Non-static method Configure::getInstance() should not be called statically in D:\www\hosts\cake\ucake-libs\cake\bootstrap.php on line 43

Strict Standards: Non-static method Configure::write() should not be called statically in D:\www\hosts\cake\ucake-libs\cake\bootstrap.php on line 82

Strict Standards: Non-static method Configure::getInstance() should not be called statically in D:\www\hosts\cake\ucake-libs\cake\libs\configure.php on line 108

大概扫了几眼,看到基本上是CakePHP框架的错误,在Google中搜索相关错误信息时发现其它框架也存在这种通病,无耐。。。

只好认真看了看错误的解释,我理解的是:程序没有按照PHP严格规定的模式编写而给的警告。想到这点于是自己又测试了几个以前写的小程序,有的也会出现这个错误。看来以后自己得注意自己的编码规范,不能一味的追求功能…

由于当前项目要进行调试,遂又将php.ini错误输出重新定义为:error_reporting = E_ALL。将E_STRICT去掉了,重启Apache…一切如常…

E. php不经过实例化也能调用非静态方法。

这种非静态的方法,在php中也可以调用,但是php已经不提倡这样调用了,会提示一个Strict standards(非标准语法的)的错误


F. php传递默认参数出错

这样是不符合php的规范,你定义的函数参数是引用传递(变量前加了&符号),但使用时却是值传递($_result=null),这里有个例子:http://www.hankcs.com/program/jie-jue-strict-standards-only-variables-should-be-passed-by-reference.html。
设置函数参数默认值应该在定义函数的地方,而不是调用的地方,而且应该把预设置默认值的参数放在后面,如上面的函数方法应该改为:
static public function unDB(&$_db, &$_result=NULL){
...

}

这样在调用这个方法的时候是可以这样的:DB::unDB($_db);即$_result可以省略

G. php报警Strict Standards:Only variables should be passed by reference in/flashplay.php on line 450

这句的意思是把一个图片的后缀扩展名接到$name变量上
比如,如果设$name的值随意为"nihao"; $ad_img中的name文件名为"b.jpg"
语句先获得"jpg",前接上一个点.再接在"nihao后面,最后得到nihao.jpg
这样写法很多,可以用strpos写,不用explode.

热点内容
压缩性粉碎性骨折 发布:2024-05-01 21:23:46 浏览:611
iphone4s怎么密码 发布:2024-05-01 21:23:38 浏览:305
csgo如何换国服服务器 发布:2024-05-01 21:03:47 浏览:782
qq改写密码是多少位数字 发布:2024-05-01 21:02:01 浏览:460
你你连接的密码是多少 发布:2024-05-01 20:59:13 浏览:476
安卓应用哪个软件最多 发布:2024-05-01 20:54:05 浏览:20
微信墙完美版php源码 发布:2024-05-01 20:17:36 浏览:483
优酷上传视频软件 发布:2024-05-01 20:17:32 浏览:270
vc与数据库连接 发布:2024-05-01 20:16:37 浏览:998
天猫在哪里修改密码 发布:2024-05-01 19:58:59 浏览:735