From f335c023de175938c29e61c02d9fa20fd2d5fb6d Mon Sep 17 00:00:00 2001 From: "xiaobo.sun" <5ini99@sohu.com> Date: Mon, 15 Feb 2016 10:18:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=9D=9Ewindows=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8BgetModelName=E8=8E=B7=E5=8F=96=E4=B8=8D?= =?UTF-8?q?=E5=88=B0basename=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit basename:在 Windows 中,斜线(/)和反斜线(\)都可以用作目录分隔符。在其它环境下是斜线(/)。 --- library/think/Model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/think/Model.php b/library/think/Model.php index 4a221173..ac1bf030 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1198,7 +1198,8 @@ class Model public function getModelName() { if (empty($this->name)) { - $this->name = basename(get_class($this)); + // 解决非windows环境下获取不到basename的bug(xiaobo.sun modify 20160215) + $this->name = basename(str_replace('\\', '/', get_class($this))); } return $this->name; }