你不能做你想做的事。
如果按照您声明的方式定义了您不想执行的操作,那么您可以在 require 函数中使用常量“模型”的唯一方法。
Why don't you write a class to do this?
<?php
class PATHS {
public $models = null;
public $views = null;
public $classes = null;
public function __construct($namespace) {
switch ($namespace) {
case 'path1' :
$this->models = 'my_custom_path/models';
$this->$views = 'my_custom_path/views';
$this->classes = 'my_custom_path/classes';
break;
case 'path2' :
$this->models = 'my_custom_path/models';
$this->$views = 'my_custom_path/views';
$this->classes = 'my_custom_path/classes';
break;
default :
$this->models = 'my_custom_path/models';
$this->$views = 'my_custom_path/views';
$this->classes = 'my_custom_path/classes';
break;
}
}
}
$paths =new PATHS('my_namespace');
echo $paths->models;
echo $paths->views;
echo $paths->classes;
?>
I don't fully understand what your end-goal is, but I think I get the gist of it, and a similar class turned into an object should accomplish what you want.
You can simply include that class in your framework where necessary.
Hope that helps