有人可以向我解释一下吗?
这两种方法有什么区别?
function some_function($foo)
{
}
Run Code Online (Sandbox Code Playgroud)
和
function some_function(foo $foo)
{
}
Run Code Online (Sandbox Code Playgroud)
在我的情况下
public function validate_something(notice $notice, $tok_id, $captcha)
{
if(something === true) {
$notice->add('info', 'Info message');
} else {
$notice->add('error', 'Error message');
}
}
Run Code Online (Sandbox Code Playgroud)
$ notice是课堂通知的对象
class notice {
private $_notice = array();
public function get_notice(){
return $this->_notice;
}
public function add($type, $message) {
$this->_notice[$type][] = $message;
}
...
}
Run Code Online (Sandbox Code Playgroud) 当url是http://example.com/mvc/login/requestsExceeded,没有执行Style.css ,
但它确实在我的登录索引页面中http://example.com/mvc/login,
如果我添加正斜杠http://example.com/mvc/login/,那么它也不起作用.
mvc =子目录中的站点
login = controller
requestsExceeded = view
.css文件在 http://www.example.com/mvc/views/themes/default/style.css
文件路径是好的因为我试过这样:
<?php if(file_exists("views/themes/{$theme}/style.css")) echo 'TEST'; ?>
<link href="views/themes/<?=$theme;?>/style.css" type="text/css" rel="stylesheet" />
Run Code Online (Sandbox Code Playgroud)
它确实回应了TEST.
这是我的简化路由器:
<?php
$controller = "Index";
$action = "index";
$query = null;
if (isset($_GET['load']))
{
$params = array();
$params = explode("/", $_GET['load']);
$controller = ucwords($params[0]);
if (isset($params[1]) && !empty($params[1]))
{
$action = $params[1];
}
if (isset($params[2]) && !empty($params[2]))
{
$query = $params[2];
}
}
$modelName = $controller;
$controller .= …Run Code Online (Sandbox Code Playgroud)