【发布时间】:2013-05-24 14:38:52
【问题描述】:
我知道这个问题已经回答了很多次了,但是我有一些我无法解决的问题。
我收到了几个关于在特定页面和特定行上分配返回值的警告。但是当我打开那个页面时,请求的行要么是空的,要么是在 cmets 下,要么是其他的..
这是一个警告和与之相关的页面代码:
不推荐使用:通过引用分配 new 的返回值是 已弃用 /home/saltushr/public_html/_classes/hr/dimedia/framework/Controller.class.php 第 25 行
不推荐使用:通过引用分配 new 的返回值是 已弃用 /home/saltushr/public_html/_classes/hr/dimedia/framework/Controller.class.php 第 26 行
代码是:
<?php
/**
* This clas instantiates the required {@link Model} and {@link View} objects.
*
* @author Berislav Lopac berislav.lopac@dimedia.hr
* @version 1.0
*/
class Controller {
var $model;
var $view;
/**
* The constructor.
* Instantiates the {@link Model} and {@link View} objects.
*
* @param $_task A String setting the base name of the instantiated objects.
* @param $_db ADOConnection object containing the connection to the database.
* @param $_input An Array with the input values required by the Model (usually the $_REQUEST array).
*/
function &Controller($_name, &$_db, $_input) {
$model = $_name . "Model";
$view = $_name . "View";
$this->model =& new $model($_db, $_input);
$this->view =& new $view($this->model);
}
/**
* Returns the associated {@link View} object.
* @return View
*/
function &getView() {
return $this->view;
}
}
?>
如您所见,第 25 行和第 26 行是空的:
21 变量 $model;
22
23 变量$视图;
24
25
26
27 /**
谁能帮我理解这是怎么回事?我在理解 PHP 方面还很陌生,可以使用一些帮助。 谢谢。
【问题讨论】:
-
哦,我在格式化代码后弄乱了行号引用...但是这么多空行太可怕了。
-
您应该在使用参考之前阅读手册:php.net/references
-
我知道,问题是这段代码不是我的。我只是想删除已弃用的警告。我在 3 页上成功了,但这一页让我很烦。 @Felix Kling,ty 用于删除空行,我会更早地这样做。只有一个问题,当我对我得到的代码进行任何更改时:解析错误:语法错误,第 1 行 /home/saltushr/public_html/_classes/hr/dimedia/framework/Controller.class.php 中的意外 T_CLASS .. . 即使我只是复制上面的代码而没有额外的空行..
-
好的,我解决了.. 删除了所有评论和空行,然后将 class Controller{ 放在
标签: php deprecated