目前在PHP中使用大型平台.
它托管的服务器最近已升级到PHP 5.4.
从那以后,我收到了很多错误消息,如:
[Sat 5月26日19:04:41 2012] [错误] PHP严格标准:非静态方法Config :: getData()不应该静态调用,假设$ this来自/xxx/Config.inc.php中的不兼容上下文第35行
示例方法定义为(注意缺少'static'关键字):
function &getData() {
$configData =& Registry::get('configData', true, null);
if ($configData === null) {
// Load configuration data only once per request, implicitly
// sets config data by ref in the registry.
$configData = Config::reloadData();
}
return $configData;
}
Run Code Online (Sandbox Code Playgroud)
这之前没有引起任何问题,我认为错误消息(导致应用程序崩溃)可能与最近升级到PHP5.4有关.
是否有PHP设置我可以修改为"忽略"缺少静态关键字?
我最近对PHP 5.4进行了更新,我收到有关静态和非静态代码的错误.
这是错误:
PHP Strict Standards: Non-static method VTimer::get()
should not be called statically in /home/jaco/public_html/include/function_smarty.php on line 371
Run Code Online (Sandbox Code Playgroud)
这是第371行:
$timer = VTimer::get($options['magic']);
Run Code Online (Sandbox Code Playgroud)
我希望有人可以提供帮助.
我在第3行的PHP代码中收到此错误,可能是什么错误?此代码取自frank在interactinet dot com上的 php手册用户注释
<?php
public function myMethod()
{
return 'test';
}
public function myOtherMethod()
{
return null;
}
if($val = $this->myMethod())
{
// $val might be 1 instead of the expected 'test'
}
if( ($val = $this->myMethod()) )
{
// now $val should be 'test'
}
// or to check for false
if( !($val = $this->myMethod()) )
{
// this will not run since $val = 'test' and equates to true
}
// this is an easy …Run Code Online (Sandbox Code Playgroud) 最近将我们的服务器升级到 5.4 并开始收到以下错误
Non-static method DB::connect() should not be called statically
Run Code Online (Sandbox Code Playgroud)
我已经上下研究了这个问题,并且提出的每个解决方案都没有奏效。我曾尝试在文件级别、目录级别和服务器级别关闭严格的错误报告。浏览器中出现的实际错误是:
DB Error: connect failed module: /path/to/login_class.php line: 49
Run Code Online (Sandbox Code Playgroud)
编辑:从 lib_app.php 发布完整代码:
<?php
/*--------------------------------------------------------------------------
$RCSfile: lib_app.php,v $
Purpose: Defines App class. This class is a container for
application global variables such as database
connection.
Copyright: 2003 ** Author Omitted **
---------------------------------------------------------------------------
Functions:
- none
Classes:
App - global application class, holds global variables
---------------------------------------------------------------------------
$Log: lib_app.php,v $
Revision 1.1.1.1 2004/08/05 23:50:39 ** Author Omitted **
--------------------------------------------------------------------------*/
if (!defined('PHP_APP'))
die('<br>'.__FILE__.': …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
class MyController {
public function newUserAction()
{
$view = new View('myfrontend');
if($this->request->isPost())
{
$form = new MyForm;
$posts = $this->request->getPosts();
if($form->isValid($posts))
{
//...
}
}
$view->display();
}
Run Code Online (Sandbox Code Playgroud)
}
因此,每次表单未正确填写时,流程将再次启动,因此每次都有"新视图('myfrontend')"等.但这是件好事吗?一次又一次地拥有一个新的视图对象.
在这里与单身人士合作不是更好吗?